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
    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号