繁体   English   中英

我想把jquery $ .ajax()方法的响应放到bootstrap popup Modal里面的目标<div>

[英]I want to put response from jquery $.ajax() method to a target <div> inside bootstrap popup Modal

我正在使用jquery .ajax()函数调用ActionMehod,并希望将响应放入Bootstrap PopupModal中定义的目标DIV标记中。

$.ajax({
    type: "GET",
    data: { "id": idVal },
    contentType : "application/json",
    url: '@Url.Action("GetAssetCalcert", "SiteReport")',
    target: "#popupModel",
    success: ShowPopup()
});

function ShowPopup() {
    $('#myModal').modal('show')
    $("#loadCalcert").attr('data-toggle', 'modal');
}

这里"#myModal"是BootstrapModal的Id,而"#popupModel"是modal-body标签内的DivID。

这实际上成功调用了actionMethod,并且我已经确认在成功时做了console.log(data)的HTML响应。 但是打开一个空的popupModal而不是渲染收到的内容。

我在这里错过了什么?

如果要将其放入模态中,则必须将成功的返回值传递给函数:

$.ajax({
    type: "GET",
    data: { "id": idVal },
    contentType : "application/json",
    url: '@Url.Action("GetAssetCalcert", "SiteReport")',
    target: "#popupModel",
    success: function(result) { 
      ShowPopup(result);
    }
});

function ShowPopup(result) {
    $('#myModal').html($(result).text());
    $('#myModal').modal('show')
    $("#loadCalcert").attr('data-toggle', 'modal');
}

AJAX - JS - 从 AJAX 响应创建表并放入<div></div><div id="text_translate"><p>在这个方法中,我以文本形式传递了这个动作的响应,但是我想使用表格格式,我该怎么做?</p><pre> function loadAditivos(){ $('#aditivoAbertoInformacoesTexto').html('&lt;div id="loaderMaiorDemandante"&gt;&lt;/div&gt;'); $("#loader").show(); var jsonHide = $('#activeJsonHide').html(); if(jsonHide) { $.ajax({ url: 'search.action', // action to be perform type: 'POST', //type of posting the data data: { dataJson: jsonHide }, // data to set to Action Class dataType: 'text', success: function (html) { $("#loader").hide(); $('#showAdditiveasText').html(html); //How to pass a tablw to That DIV? }, }); } }</pre><p> 如何使用表格格式将此数据传递给 div: "$('#showAdditiveasText').html(html)"?</p><p> 例子:</p><pre> [ { "UserID": 1, "UserName": "rooter", "Password": "12345", "Country": "UK", "Email": "sac@gmail.com" }, { "UserID": 2, "UserName": "binu", "Password": "123", "Country": "uk", "Email": "Binu@gmail.com" }, { "UserID": 3, "UserName": "cal", "Password": "123", "Country": "uk", "Email": "cal@gmail.com" }, { "UserID": 4, "UserName": "nera", "Password": "1234", "Country": "uk", "Email": "nera@gmail.com" } ]</pre></div>

[英]AJAX - JS - Create a table from a AJAX response and put inside a <div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 a href 在模态弹出窗口内不起作用不是 BOOTSTRAP,不是 JQUERY AJAX - JS - 从 AJAX 响应创建表并放入<div></div><div id="text_translate"><p>在这个方法中,我以文本形式传递了这个动作的响应,但是我想使用表格格式,我该怎么做?</p><pre> function loadAditivos(){ $('#aditivoAbertoInformacoesTexto').html('&lt;div id="loaderMaiorDemandante"&gt;&lt;/div&gt;'); $("#loader").show(); var jsonHide = $('#activeJsonHide').html(); if(jsonHide) { $.ajax({ url: 'search.action', // action to be perform type: 'POST', //type of posting the data data: { dataJson: jsonHide }, // data to set to Action Class dataType: 'text', success: function (html) { $("#loader").hide(); $('#showAdditiveasText').html(html); //How to pass a tablw to That DIV? }, }); } }</pre><p> 如何使用表格格式将此数据传递给 div: "$('#showAdditiveasText').html(html)"?</p><p> 例子:</p><pre> [ { "UserID": 1, "UserName": "rooter", "Password": "12345", "Country": "UK", "Email": "sac@gmail.com" }, { "UserID": 2, "UserName": "binu", "Password": "123", "Country": "uk", "Email": "Binu@gmail.com" }, { "UserID": 3, "UserName": "cal", "Password": "123", "Country": "uk", "Email": "cal@gmail.com" }, { "UserID": 4, "UserName": "nera", "Password": "1234", "Country": "uk", "Email": "nera@gmail.com" } ]</pre></div> 如何将ajax的响应定位到单击的特定div 使用jquery调用Action Method之后,无法将响应放入定义的目标中 <div> ? 使用Ajax将值放在Spring MVC中的引导程序模式弹出字段值内,以从数据库获取数据 从jquery弹出模式调用Action方法 如何禁用div(popup)内部通过Ajax响应接收的提交按钮? 将jQuery(AJAX)的结果设置为Bootstrap模式 带有 JQuery 和 AJAX 的 Bootstrap 4 模态? 从模式弹出窗口加载时,ajax响应返回页面html
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM