drsvw88664 2013-08-28 19:19
浏览 113

AJAX函数返回状态0

$.ajax({
   type: "POST",
   url: "check-email",
   data: {email: "name@example.com"},
   success: function(data)
   {
    // success part here        
   },
   error: function(xhr)
   {
    alert(xhr.status);
   }
});

This will call another PHP file. But the sad thing is the error part is executed always with xhr.status printing as 0. What would be the problem?

Note:
1. This works perfectly in the local.
2. Both the script, check-email page is located in the same server.
3. The server is secured with https and it is in WWW version.

Update:

error: function(jqXHR, textStatus, errorThrown)
{
  alert(textStatus, errorThrown);
}

This prints simply as "error".

  • 写回答

1条回答 默认 最新

  • dox90448 2013-08-28 20:41
    关注

    I would have done this as a comment but the code would be a nightmare.

    In your PHP page write this somewhere:

    <?php
    echo '<pre>'.print_r($_POST, true).'</pre>';
    echo '<pre>'.print_r($_GET, true).'</pre>';
    ?>
    

    Now:

    1. Open up your Developer tools (Chrome) or Firebug (FireFox) and visit the Network tab.
    2. Refresh your page that makes the AJAX call
    3. Find the AJAX call to "check-email" in the Network tab and click it
    4. What do you see?
    5. Also there is a sub-tab called "Headers" in the developer tools, take a look at it
    评论

报告相同问题?