我正在使用科爾多瓦來創建一個簡單的登錄窗體的移動應用程序。問題是,只要我輸入了錯誤的用戶名和密碼,我就可以從服務器獲取XML中的INVALID INFORMATION的響應。 但是,當我輸入有效的用戶名和密碼,我得到登錄控制檯作爲XHR失敗加載:POST。XHR失敗加載:在科爾多瓦的POST
任何人都可以幫助我解決這個問題嗎?
$(document).ready(function(){
$("#login").click(function(){
$.ajax({
url: "http://remoteServerIP/login.do",
data:{
password:$('#pass').val(),
method:"login",
userName:$('#uname').val(),
cType:"LOGIN"
},
type:'post',
dataType: 'xml',
async: true,
contentType:"application/x-www-form-urlencoded",
success: function(result){
alert("Data: "+result.data);
},
error: function(xhr, ajaxOptions, thrownError){
alert("msg: "+thrownError.message+" , status: "+xhr.status);
}
});
});
});
config.xml文件: -
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.MyApp.App" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<preference name = "SplashScreen" value = "screen" />
<preference name = "SplashScreenDelay" value = "4000" />
<preference name = "SplashMaintainAspectRatio" value = "true" />
<preference name="Orientation" value="portrait"/>
<name>DikshaTouch</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<!-- <access origin="*" /> -->
<access origin="http://remoteServerIP" subdomain="true" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
<icon src="www/img/icon.png" density="ldpi" />
<icon src="www/img/icon.png" density="mdpi" />
<icon src="www/img/icon.png" density="hdpi" />
<icon src="www/img/icon.png" density="xhdpi" />
<icon src="www/img/icon.png" density="xxhdpi" />
<icon src="www/img/icon.png" density="xxxhdpi" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>`
任何控制檯錯誤404,500? – madalinivascu
不,只有當我輸入有效數據時XHR加載失敗。感謝您的回覆 – AkshayPalekar
我沒有在您的ajax請求中看到任何console.log,所以這個錯誤是來自另一個代碼 – madalinivascu