Jquery 为什么$().load()可以工作,而$.ajax()不能在phonegap应用程序中工作?
我有下面一段代码,它试图从web加载XML文件Jquery 为什么$().load()可以工作,而$.ajax()不能在phonegap应用程序中工作?,jquery,jquery-mobile,cordova,Jquery,Jquery Mobile,Cordova,我有下面一段代码,它试图从web加载XML文件 $.ajax({ url: 'http://www.kumarchetan.com/blog/feed/', success: function(xhrresponse){ $('#container').html(xhrresponse);//does nothing navigator.notification.alert("Data Loaded: " + typeof xhrresponse)
$.ajax({
url: 'http://www.kumarchetan.com/blog/feed/',
success: function(xhrresponse){
$('#container').html(xhrresponse);//does nothing
navigator.notification.alert("Data Loaded: " + typeof xhrresponse);//tells me its an object
},
error: function(){
navigator.notification.alert("PC LOAD LETTER");
}
});
我也尝试过使用$.get,但不起作用。我将此代码替换为以下代码
$('#hiddenContainer').load('http://www.kumarchetan.com/blog/feed/');
它就像魅力一样。托管XML文件的服务器在服务器端没有任何特殊的操作
编辑
我尝试添加数据类型:'xml',它也不起作用 您是否尝试过显式设置数据类型?比如:
$.ajax({
url: 'http://www.kumarchetan.com/blog/feed/',
success: function(xhrresponse){
$('#container').html(xhrresponse);//does nothing
navigator.notification.alert("Data Loaded: " + typeof xhrresponse);//tells me its an object
},
error: function(){
navigator.notification.alert("PC LOAD LETTER");
},
dataType: 'xml'
});
或
意识到在开始使用XML响应之前,我必须添加5秒的超时 我忘了提到我也添加了数据类型参数,但它不起作用,我会更新这个问题。你是在为iOS开发应用程序吗?
$.get('http://www.kumarchetan.com/blog/feed/', function(xhrresponse){
$('#container').html(xhrresponse);//does nothing
navigator.notification.alert("Data Loaded: " + typeof xhrresponse);//tells me its an object
}, 'xml');