Phonegap 애플리케이션을 개발하고 jQuery Mobile을 사용하고 있습니다. PC에서 Firefox를 통해 개발 및 테스트 중이므로 여기에 설명 된 문제는 Phonegap으로 수행 할 작업이 없습니다. -이 내용은 Firefox PC 문제입니다.Phonegap jQuery ajax 요청이 작동하지 않습니다.
다음 코드는 작동하지 않으며, 올바른 방향으로 날 :
var loadWeather = function()
{
// Request absetzen
$.ajax(
{
// the URL for the request
url : 'http://www.google.com/ig/api',
// the data to send (will be converted to a query string)
data : {
weather : 'Vienna'
},
// whether this is a POST or GET request
type : 'GET',
// the type of data we expect back
dataType : 'xml',
// code to run if the request succeeds; the response is passed to the function
success : function(xml)
{
parseXML(xml);
},
// code to run if the request fails;
// the raw request and status codes are passed to the function
error : function(xhr, status)
{
alert('Error retreiving weather!');
}
});
}
상태는 내가 모든 jQuery를의 이유에 대한 모든 정보를 얻을하지 않습니다 "오류", xhr.readyState = 0, xhr.status = 0입니다. 요청이 실행되고 응답 헤더 (Firebug)는 다음과 같습니다.
Accept: application/xml, text/xml, */*; q=0.01
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Connection: keep-alive
Host: www.google.com
Origin: null
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1
및 200 OK. 그렇다면 왜 내가 오류 케이스에 뛰어 들고 있을까요? xhr.isRejected()는 참이라고 말합니다. 이것은 무엇을 의미 하는가?
(XML 대신 시도) JSONP –
크로스 도메인 원점 제한으로 인해 일부 프록시 스크립트없이 실제 요청으로 테스트 할 수 없습니다. 이 API는 JSONP를 지원하지 않습니다. 하지만 크로스 도메인 영역이 없기 때문에 Phonegap 내부에서 작동 할 것입니다. – dfsq
@ dfsg : 귀하의 의견이 답변 일 경우, 나는 그것을 선택했을 것입니다. 고맙습니다! – ChrLipp