我有这个 jQuery 代码:
$.ajax({
type: "POST",
url: "/problems/vote.php",
dataType: "json",
data: dataString,
success: function(data)
{
// ? :)
alert (dataString);
},
error : function(data)
{
alert("ajax error, json: " + data);
//for (var i = 0, l = json.length; i < l; ++i)
//{
// alert (json[i]);
//}
}
});
当我使用它时,我在警报中收到如下神秘内容:object XMLHTTPReqest
如何实际获取从 AJAX 传入的值?
谢谢!
最佳答案
有几种方式:
console.log(data); // allows you to view your object in a tree in the console
或
alert(JSON.stringify(data)); // alerts a serialized string of the object
或者在 chrome/safari 和 firefox (firebug) 中设置一个断点并检查一下。
关于javascript - 如何理解 jQuery 返回的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7669273/