开发者

jQuery/Ajax/javascript in FireFox Error when using $.post/$.get

uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost/scripts/jQuery.js :: anonymous :: line 808" data: no]

Line 0

is the error i get when i bring up firebug. This only happens in firefox开发者_开发百科 (and maybe other browsers) but the code works fine in IE8.

I have codes like this in jquery:

$("#Logout").live("click", function (e) {
  e.preventDefault(e);
  $.post("/logout.php", {}, function () {
    //--a bunch of animations--//
    window.location = "/login.php";
  }
});

I have no idea whats wrong as even the error message is not helpful at all..

inside logout.php:

<?php
  session_start();
  session_destroy();
?>

Also dont work if I used GET or inserted phantom data. Or is there a more elegant way to do this?


The simplest way to debug this type of error is to set a breakpoint in the code, and step through it until you get the error, or to comment out parts of the code you think might cause the error. Start by commenting out the entire event callback function, and if the error is gone, uncomment different lines. When you have found out what line caused it, you might also find out why it caused it. If you don't know, ask here.

Without your entire code it is difficult for us to tell you what causes the problem.


It's really hard to decode those types of error messages. What I'd suggest doing is since it sounds like you don't have too much code, remove a few of those lines and see if it fixes the error. Just keeps removing/replacing code until the error goes away, and that's where the trouble is.

That's typically how I try to find it if I get general error messages like that. And usually the problem is with the last thing that I touched.


Solved.

I have no idea why is it like that. the error didn't lie in $.get but one of the animations.

since i had animations before the actual logout, i needed to delay the logout, and thus:

$("#Logout").live("click", function(e) {
  e.preventDefault();
  $.get("/logout.php", {}, function() {
    //--bunch of animations--//
    $(this).animate({delay:1}, DURATION, function() {
       window.location = '/login.php';
    });
  });
});

it worked after i changed "$(this).animate(..)" to something else eg. "$("body").animate(..)". kinda bumped why firefox reads $(this).animate to an error like that. #Logout is an anchor btw

eg

<a id='Logout' href='#'>Logout</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜