weixin_33695082 2010-06-22 15:02 采纳率: 0%
浏览 20

jQuery帖子停止工作

I have a web application that I wrote using JQuery. I used the $.post methods throughout the application including the login screen. It was working fine and now suddenly out of the blue, it no longer works. The post response now returns null, however; if I manually type in the post, it returns the JSON code that I would expect.

A few things that might be helpful: 1.) I'm linking against the Google's hosting of JQuery. 2.) I have not made any changes to my code or site. It was working fine for about a week before this morning. 3.) Occasionally, the jquery post request does work. Especially when I'm slowly stepping through the code.

Here's a snippit of the code that's failing:

function TryLoggingIn()
{
$.post(
    "login.php",
    {action: "login", username: $("#_uxUsername").val(), password: $("#_uxPassword").val(), redirect: $("#_uxRedirect").val()},
    function(data)
    {
        if (data.response == "error")
        {
            $("#_uxErrorBox").slideUp();
            $("#_uxErrorBox").slideDown();
            $("#_uxErrorText").text(data.message);
            $(".widgetErrorIcon").show();
        }
        else
        {
            window.location = data.newlocation;
        }
    },
    "json"
 );

}

What's strange is that when it does fail and I'm watching it using WireShark, I never see the post request made, yet it enters the success function with data set to null.

  • 写回答

1条回答 默认 最新

  • weixin_33701617 2010-06-22 15:09
    关注

    One thing to check, especially if WireShark isn't seeing any request, is whether the Ajax destination is being cached by your browser. One approach to prevent this is to append a meaningless querystring or anchor to your URL with a random number in it.

    Firebug is also useful for this kind of thing, although using WireShark was a good idea also.

    Lastly, it's often useful to rewrite your ajax call using jQuery.ajax() function rather than jQuery.post(), since that will allow you to tweak a lot more things, such as the timeout value, the "cache" flag, etc.

    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services