간단한 로그인 양식으로 모바일 앱을 개발하는 데 cordova를 사용하고 있습니다. 문제는 잘못된 사용자 이름과 암호를 입력 할 때마다 서버에서 XML의 잘못된 정보로 응답을받을 수 있다는 것입니다. 하지만 유효한 사용자 이름과 암호를 입력하면 콘솔에 로그인 할 때 XHR로드 실패 : POST.XHR로드 실패 : POST in cordova
누구든지이 문제를 해결할 수 있습니까?
$(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
아약스 요청에 console.log가 표시되지 않으므로이 오류는 다른 코드에서 발생했습니다 – madalinivascu