在成功运行另一个功能之后,我想根据当前单选按钮的选择调用特定单选按钮的数据url。
这是我的单选按钮组:
<form action="/ALS/RejectRecordAnalysis/1" method="post">
<span id="wrapper_cra" class="form-group">
<span><label for="">TEST1</label></span>
<span id="button-spacing">
<input class="" data-url="/ALS/RejectRecordAnalysisCRA?business=1&_cra_id=1" id="radiobutton1" name="_cra.agency_name" type="radio" value="{ id = 1 }" />
</span>
<span><label for="">TEST2</label></span>
<span id="button-spacing">
<input class="" data-url="/ALS/RejectRecordAnalysisCRA?business=1&_cra_id=2" id="radiobutton2" name="_cra.agency_name" type="radio" value="{ id = 2 }" />
</span>
<span><label for="">TEST3</label></span>
<span id="button-spacing">
<input class="" data-url="/ALS/RejectRecordAnalysisCRA?business=1&_cra_id=3" id="radiobutton3" name="_cra.agency_name" type="radio" value="{ id = 3 }" />
</span>
<span><label for="">TEST4</label></span>
<span id="button-spacing">
<input class="" data-url="/ALS/RejectRecordAnalysisCRA?business=1&_cra_id=4" id="radiobutton4" name="_cra.agency_name" type="radio" value="{ id = 4 }" />
</span>
</span>
</form>希望从这个成功块运行:编辑,我在成功块中添加了一些javascript。但是,.val()函数只返回所选单选按钮的id,并在尝试$.ajax调用时抛出一个错误。
success: function (result) {
if (result.success) {
$('#myModal').modal('hide');
var checked = $("#wrapper_cra input[type='radio']:checked").val();
$.ajax({
url: $(checked).data('url'),
type: 'GET',
data: checked,
success: function (result) {
$("#scroll-grid").html(result);
}
});
} else {
$('#myModalContent').html(result);
bindForm();
}
}发布于 2016-10-20 15:36:49
我已经解决了上面的问题。在我的成功块中,我添加了以下代码:
var checked = $("#wrapper_cra input[type='radio']:checked").attr('data-url');
$.ajax({
url: checked,
type: 'GET',
success: function (result) {
$("#scroll-grid").html(result);
}选中的变量包含适当单选按钮的data- url,然后$.ajax函数运行url,我将返回一个html部分视图,其中包含更新的信息。
https://stackoverflow.com/questions/40157346
复制相似问题