繁体   English   中英

如何通过Ajax文本响应中的ID获取值

[英]How to get value by id from ajax text response

下面是我的代码,它不起作用,如何通过响应中的id来数据? 请提供此问题的任何解决方案。

function loadStatus(uri,id)
{
    waitingDialog.show('Loading', {dialogSize: 'sm'});
    $.ajax({
        method : "GET",
        dataType : "text",
        url : uri,
        xhrFields : {
            withCredentials : true
        },
        crossDomain : true,
        contentType : "application/x-www-form-urlencoded;charset=UTF-8"

    }).done(function(msg) {
        waitingDialog.hide();
        alert(msg);
        // getting value by id
        var contractID= $msg.filter('#contractID').text();
        // getting value by id
        var contractID=$(msg).find('#contractID').html();
        alert(contractID);
    });
    return false;
}

这取决于您希望从uri获得的数据类型。 在完成的函数中,您不应查询html元素。 只要提醒味精,看看你得到什么。

var contractID= $msg.filter('#contractID').text();

$ msg没有在任何地方定义...您使用的下一行

$(msg)

这是你的意思吗?

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM