1

在 Safari 和 Firefox 中,代码的响应部分不起作用(即来自 PHP-->Ajax-->jQuery)。变量肯定使它对 PHP 很好(使用 测试mail()),所以它可能代表我的一些小错误!

jQuery:

$.ajax({
    type: "POST",
    dataType: "json",
    data: postData,
    url: "http://www.kudiclub.com/test/login/?loginsub",
    success: function(data){
        if(data.success==false){
            $("#login .error").html(data.reply).show();
            $("#login-email").val(data.email);
            $("#password").val("");
        }else{
            window.location = data.ref;
        }
    }
});

PHP:

$data = array('success' => false, 'reply' => 'Username and password did not match.', 'email' => $email);
print json_encode($data);
return;

希望有人可以提供帮助。谢谢,尼克。

解决方案

经过一番折腾,事实证明它没有将完整的 URL 视为相对路径。改变urlto就可以'/test/login/?loginsub'了。

4

1 回答 1

0

服务器说:Content-Type:text/html。不是 json 文档(application/json)。

http://www.kudiclub.com/test/login/?loginsub

GET /test/login/?loginsub HTTP/1.1
Host: www.kudiclub.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Cookie: PHPSESSID=060b8210adfb3c67ff792b9471c7fa1c
Cache-Control: max-age=0

HTTP/1.1 200 OK
Date: Thu, 02 Aug 2012 22:12:10 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Keep-Alive: timeout=2, max=200
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
于 2012-08-02T22:14:10.873 回答