【发布时间】:2012-02-02 08:18:15
【问题描述】:
我有一个 php 脚本,它返回序列化的 php 数据。我尝试使用 jQuery 1.7 中的 $.ajax() 方法接收这些数据。 Here 就是一个例子。
$.ajax({
url: 'http://input.name/get.php?do=lookup' + '&domain=twittorama&tlds=.ru,.com,.net,.comf.ru',
type: 'GET',
dataType: 'text',
cache: 'false',
complete: function(res) {
alert('COMPLETE() done');
console.log(res);
}
});
在控制台中我只看到
Object { readyState=0, status=0, statusText="error"}
那么,我做错了什么?你能帮帮我吗?
UPD
有趣的通知:如果我使用 JSONP dataType 请求可以接收数据,但不能处理它。 Here is an example.
$.ajax({
url: 'http://input.name/get.php?do=lookup',
data: 'domain=twittorama&tlds=.ru,.com,.net,.comf.ru',
dataType: 'jsonp',
cache: false,
success: function(data) {
alert("Data: "+data);
},
error: function(jqXHR, textStatus, errorThrown) {
alert("Error: "+textStatus);
console.log(jqXHR);
}
});
【问题讨论】:
标签: javascript jquery ajax deserialization