2010-07-31 2 views
1

JQuery.post()의 콜백 함수는 JQuery 1.3.2에서는 호출되지만 1.4.2에서는 호출되지 않습니다. 성공하지 못한 버전 사이에서 무엇이 바뀌 었는지 찾아 보려고했습니다.JQuery.post() 콜백 함수는 1.3.2에서 호출되었지만 1.4.2에서는 호출되지 않았습니다.

<html> 
<head> 
<script type="text/javascript" 
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" 
></script> 
<script type="text/javascript"> 
function f() { 
    var j; 
    $.post('/python/publisher/jqueryjson.py', {x: 1}, function(j){g(j);}, 'json'); 
} 
function g(j) { 
    console.log(j.result); 
} 
</script> 
</head> 

<body> 
<input type="button" onclick="f();"> 
</body> 
</html> 

Response Headers 

HTTP/1.1 200 OK 
Date: Sat, 31 Jul 2010 18:55:26 GMT 
Server: Apache/2.2.3 (CentOS) 
Content-Length: 14 
Connection: close 
Content-Type: application/json 

Request Headers 

POST /python/publisher/jqueryjson.py HTTP/1.1 
Host: teste.dkt 
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.7) Gecko/20100723 Fedora/3.6.7-1.fc13 Firefox/3.6.7 
Accept: application/json, text/javascript, */* 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Keep-Alive: 115 
Connection: keep-alive 
Content-Type: application/x-www-form-urlencoded; charset=UTF-8 
X-Requested-With: XMLHttpRequest 
Referer: http://teste.dkt/python/publisher/jqueryjson.html 
Content-Length: 3 
Pragma: no-cache 
Cache-Control: no-cache 

답변

1

난 당신 (POST에/동기화 모드 필요한 경우) $ 아약스()를 사용하여 이상 변경할 수 있습니다 해결 방법으로 생각, 하나의 "성공"콜백 동안 몇몇 다른 사람 (저를 위해 작동하는 것 같다 "완료"와 같은)하지 않습니다.

EDIT : jQuery 1.4+에서 좀 더 엄격한 JSON 구문 분석 준수가있을 수 있습니다. http://jsonlint.com/과 같은 사이트에서 JSON 출력을 확인하는 것이 좋습니다. 유효성을 확인하지 않으면 콜백을받지 못할 수 있습니다. 단일 대 큰 따옴표를 확인하십시오.

EDI2 : jQuery를 1.4 JSON 구문 분석 여기에 정보를 참조하십시오 :

http://yehudakatz.com/2010/01/15/jquery-1-4-and-malformed-json/

+0

예 문제가 있었다 잘못된 JSON. –

관련 문제