jquery (ajax) redirect to another domain
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the jquery json request in the following format: JSON request: $.getJSON('http://xyz.com',function(result) {}); If the request fails(server not responds), how do i redirect to another domain. for example " http://zxy.com ".(we maintaining the same code in another server) 回答1: Did you try this? function addImage(item) { $("<img/>").attr("src", item.media.m).appendTo("#images"); } var jqxhr = $.getJSON("http://xyz.com",function(data) { $.each(data.items, function(i,item){ //sample addImage(item); }) .error(function() { var jqxhrFailover