getJSON的问题求指点~~ jsjqueryjson 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下面是jquery官网的例子,实现这个 .fail?// Assign handlers immediately after making the request,// and remember the jqxhr object for this requestvar jqxhr = $.getJSON( "example.json", function() { console.log( "success" );}) .done(function() { console.log( "second success" ); }) .fail(function() { console.log( "error" ); }) .always(function() { console.log( "complete" ); }); // Perform other work here ... // Set another completion function for the request abovejqxhr.complete(function() { console.log( "second complete" );}); 试过了,如果没涉及到跨域的话,可以用这个方法,涉及到跨域就失效了看这里内容很多http://api.jquery.com/jQuery.ajax/var jqxhr = $.ajax( "example.php" ) .done(function() { alert( "success" ); }) .fail(function() { alert( "error" ); }) .always(function() { alert( "complete" ); }); // Perform other work here ... // Set another completion function for the request abovejqxhr.always(function() { alert( "second complete" );}); 跨域使用JSONP$.getJSON('http://127.0.0.1/PGapJQM4Net/WS4JQM.asmx/GetTestList?callback=?', { //无参数 }).done(function (response) { console.log(response.success); if(response.success){ var htmlStr = ""; $.each(response.data,function(i,o){ htmlStr += '<li><a href="http://www.baidu.com">'+o.id+' ' + o.name+'</a></li>'; }); $("#lvtest").html(htmlStr); $("#lvtest").listview("refresh"); } }).fail(function (jqxhr, textStatus, error) { console.log(error); });自动产生回调 $.getJSON('http://127.0.0.1/PGapJQM4Net/WS4JQM.asmx/GetTestList?callback=?', { //无参数 }).done(function (response) { console.log(response.success); if(response.success){ var htmlStr = ""; $.each(response.data,function(i,o){ htmlStr += '<li><a href="http://www.baidu.com">'+o.id+' ' + o.name+'</a></li>'; }); $("#lvtest").html(htmlStr); $("#lvtest").listview("refresh"); } }).fail(function (jqxhr, textStatus, error) { console.log(error); }); js获取不到返回的php里的class 帮忙修改下JS广告代码! 请教如何做到这样的提示功能? 如何在一个动态生成的方法中,获取节点的this指针 十六进制转十进制怎么转 请教简单的编辑器写法 点击一个链接出现下拉菜单,鼠标移开菜单消失 如何在Javascript判断一个对象(文本框)是否获得焦点? 如何在网页中编辑图片,可以剪切,改变大小,旋转之类? js实现会议室预约功能的 问题 js实现下载快捷方式-将站点的快捷打开方式放到桌面 引用了母板页的页面,如何使用JavaScirpt?
// and remember the jqxhr object for this request
var jqxhr = $.getJSON( "example.json", function() {
console.log( "success" );
})
.done(function() {
console.log( "second success" );
})
.fail(function() {
console.log( "error" );
})
.always(function() {
console.log( "complete" );
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.complete(function() {
console.log( "second complete" );
});
试过了,如果没涉及到跨域的话,可以用这个方法,
涉及到跨域就失效了
看这里内容很多
http://api.jquery.com/jQuery.ajax/var jqxhr = $.ajax( "example.php" )
.done(function() {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" );
});
// Perform other work here ...
// Set another completion function for the request above
jqxhr.always(function() {
alert( "second complete" );
});
$.getJSON('http://127.0.0.1/PGapJQM4Net/WS4JQM.asmx/GetTestList?callback=?', {
//无参数
}).done(function (response) {
console.log(response.success);
if(response.success){
var htmlStr = "";
$.each(response.data,function(i,o){
htmlStr += '<li><a href="http://www.baidu.com">'+o.id+' ' + o.name+'</a></li>';
});
$("#lvtest").html(htmlStr);
$("#lvtest").listview("refresh");
}
}).fail(function (jqxhr, textStatus, error) {
console.log(error);
});
自动产生回调
$.getJSON('http://127.0.0.1/PGapJQM4Net/WS4JQM.asmx/GetTestList?callback=?', {
//无参数
}).done(function (response) {
console.log(response.success);
if(response.success){
var htmlStr = "";
$.each(response.data,function(i,o){
htmlStr += '<li><a href="http://www.baidu.com">'+o.id+' ' + o.name+'</a></li>';
});
$("#lvtest").html(htmlStr);
$("#lvtest").listview("refresh");
}
}).fail(function (jqxhr, textStatus, error) {
console.log(error);
});