[英]How to get value by id from ajax text response
below is my code, it is not working, how to data by id from response ? 下面是我的代码,它不起作用,如何通过响应中的id来数据? please provide any solution to this issue. 请提供此问题的任何解决方案。
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;
}
It depends upon the type of data you are expected to get from the uri. 这取决于您希望从uri获得的数据类型。 Inside your done function you are not supposed to query a html element. 在完成的函数中,您不应查询html元素。 Just alert msg and see what you are getting. 只要提醒味精,看看你得到什么。
var contractID= $msg.filter('#contractID').text();
$msg is not defined anywhere ... next line you use $ msg没有在任何地方定义...您使用的下一行
$(msg)
is that what you meant? 这是你的意思吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.