Skip to main content

Bug Tracker

Side navigation

#10160 closed bug (worksforme)

Opened August 29, 2011 12:06PM UTC

Closed August 30, 2011 03:27PM UTC

Last modified August 31, 2011 09:12AM UTC

AJAX errors are not reported in Firefox Error console

Reported by: macrae_dj Owned by: macrae_dj
Priority: low Milestone: None
Component: ajax Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

If a javascript run-time error is present in the success handler of an $.ajax call it is not reported in the Firefox error console (or the Firebug console). This makes debugging very difficult.

Platform: Windows 7 64-bit, Firefox 5.0.1, jQuery 1.6.2.

I have also tested in firefox safe-mode.

The contents of 2 files are below. The file that initiates the ajax and the file that responds to the ajax request.

If you uncomment the first 'alert' statement - you will get an error reported as expected. However if you uncomment the second 'alert' statement (inside the 'success' handler) the javascript will crash but there will be no error message in the error console.

ajax_test2.html

<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"></script>
<script type="text/javascript">

$(document).ready(function(){

    //alert(missingVariable1);           //uncomment -> get error reported

    $.ajax({
        url: "ajax_test2_process.php",
        data: "send=hello",
        async: false,
        success: function(data){
            $("#results").append(data);
            //alert(missingVariable2);   //uncomment -> no error reported
            $("#results").append(" finished ");
            }
        });
});

</script>
</head>
<body>
<div id="results"></div>
</body>
</html>

ajax_test2_process.php

<?php
    echo "received: " . $_REQUEST['send'];
?>
Attachments (0)
Change History (17)

Changed August 29, 2011 01:32PM UTC by timmywil comment:1

component: unfiledajax
owner: → macrae_dj
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

I am unable to reproduce this issue. http://jsfiddle.net/timmywil/bHGGW/

Changed August 29, 2011 03:11PM UTC by rwaldron comment:2

A note of advice: Unless you really understand the behaviour produced by setting async: false I would recommend sticking with the default, which is async: true (this is implicit).

Changed August 30, 2011 01:28PM UTC by macrae_dj comment:3

status: pendingnew

Timmywil, I think maybe my bug report was not very clear. The issue is that errors are not getting reported in the console. Please can you recheck this. I have tried this on 3 machines and have asked others to confirm what I am receiving...

http://stackoverflow.com/questions/7243098/errors-in-jquery-ajax-are-not-getting-reported

It seems clear that this issue does exist.

I understand the attraction of jsfiddle but, in this case, I think its best to use the direct code (as the bug may be due to an interaction with the browser). I.e its best to keep the javascript and the environment the same so the bug can be reproduced reliably (eg lack of an error console on jsfiddle and not being sure if firebug-lite will behave just like firebug etc).

I dont know if this is a bug or its there by necessity - in which case the bug is really a request for a warning in the documentation as I've spent a lot of time trying to resolve this.

There is a link to the web page here...

http://www.alisonstrachan.co.uk/tests/ajax2/ajax_test2.html

Run this and if you dont receive an error in the error console - then you have reproduced the issue.

I have tried to use the Edge version of jQuery but I cant find the link for it (sorry dont know how to use git).

Changed August 30, 2011 02:57PM UTC by timmywil comment:4

_comment0: @macrae_dj: I see no reason why you should not be able to reproduce the issue on jsfiddle unless php is required (in that case, it is usually an issue with the server side code and not jQuery). jsfiddle is a normalized environment where we can make proper assumptions. If the issue cannot be reproduced there, it is probably not an issue with jQuery. A test page on your own server does not really help because we need something editable and we need to rule out user error. \ \ PS- you can link the git version of jquery here: http://code.jquery.com/jquery-git.js \ PSS - jsfiddle is like any other webpage in that it will log to the existing browser console if it exists. Firebug lite is not required and something to keep in mind is that regular firebug will override it and take over logging whether lite is present or not. To see the test page created on jsfiddle by itself, you can add /show to the end of url.1314716266961471
status: newpending

@macrae_dj: I see no reason why you should not be able to reproduce the issue on jsfiddle unless php is required (in that case, it is usually an issue with the server side code and not jQuery). jsfiddle is a normalized environment where we can make proper assumptions. If the issue cannot be reproduced there, it is probably not an issue with jQuery. A test page on your own server does not really help because we need something editable and we need to rule out user error.

PS- you can link tothe git version of jquery here: http://code.jquery.com/jquery-git.js

PSS - jsfiddle is like any other webpage in that it will log to the existing browser console if it exists. Firebug lite is not required and something to keep in mind is that regular firebug will override it and take over logging whether lite is present or not. To see the test page created on jsfiddle by itself, you can add /show to the end of url.

Changed August 30, 2011 03:16PM UTC by macrae_dj comment:5

_comment0: Timmywil, lets first just see if you can reproduce the bug. \ \ Please click on this link and if you DONT receive an error in the error console - then you have successfully reproduced the issue .... \ [http://www.alisonstrachan.co.uk/tests/ajax2/ajax_test2.html] \ \ I have tried your link: [http://jsfiddle.net/timmywil/bHGGW/] and I can report I do not receive an error in the Firefox error console (i.e. the bug exists). From your first post I understand that you did receive an error message (as you said you could not reproduce the bug). Can you confirm this please. \ \ Depending on your results we can take it from there. \ 1314717510109569
_comment1: Timmywil, lets first just see if you can reproduce the bug. \ \ Please click on this link and if you DONT receive an error in the error console - then you have successfully reproduced the issue .... \ [http://www.alisonstrachan.co.uk/tests/ajax2/ajax_test2.html] \ \ I have tried your link: [http://jsfiddle.net/timmywil/bHGGW/] and I can report I do not receive an error in the Firefox error console (i.e. the bug exists). From your first post I understand that you did receive an error message (as you said you could not reproduce the issue). Can you please confirm this. \ 1314717578061574
_comment2: Timmywil, lets first just see if you can reproduce the bug. \ \ Please click on this link and if you DONT receive an error in the error console - then you have successfully reproduced the issue .... \ [http://www.alisonstrachan.co.uk/tests/ajax2/ajax_test2.html] \ \ I have tried your link: [http://jsfiddle.net/timmywil/bHGGW/] and I can report I do not receive an error in the Firefox error console (i.e. the bug exists). From your first post I understand that you did receive an error message (as you said you were unable to reproduce the issue). Can you please confirm this. \ 1314717749436510
_comment3: Timmywil, lets first just see if you can reproduce the bug. \ \ Please click on this link and if you DONT receive an error in the error console - then you have successfully reproduced the issue .... \ [http://www.alisonstrachan.co.uk/tests/ajax2/ajax_test2.html] \ \ I have tried your link: [http://jsfiddle.net/timmywil/bHGGW/] and I can report I do not receive an error in the Firefox error console (i.e. the bug exists). From your first post I understand that you did receive an error message (as you said you were unable to reproduce the issue). Can you please confirm this. \ \ (When you stated that you couldnt reproduce the issue - I suspected jsfiddle may have been interfering with things and thought it useful to by pass it). \ 1314717815515090
status: pendingnew

Timmywil, lets first just see if you can reproduce the bug.

Please click on this link and if you DONT receive an error in the error console - then you have successfully reproduced the issue ....

http://www.alisonstrachan.co.uk/tests/ajax2/ajax_test2.html

I have tried your link: http://jsfiddle.net/timmywil/bHGGW/ and I can report I do not receive an error in the Firefox error console (i.e. the bug exists). From your first post I understand that you did receive an error message (as you said you were unable to reproduce the issue). Can you please confirm this.

(When you stated that you couldnt reproduce the issue - I suspected jsfiddle may have been interfering with things and therefore suggested by-passing it).

Changed August 30, 2011 03:27PM UTC by rwaldron comment:6

_comment0: http://gyazo.com/23fc8614479932f989e101ab47041226.png \ \ \ Works for me.1314718421326211
resolution: → worksforme
status: newclosed

Changed August 30, 2011 03:31PM UTC by macrae_dj comment:7

Thanks rwaldron. Could you please also quickly test the direct link http://www.alisonstrachan.co.uk/tests/ajax2/ajax_test2.html

This may help to narrow things down. Its just that I had other folk test with this link and they reported that no error message was received. If you do get an error message, can you let me know the details of you firefox version etc just in case this is has some bearing on the issue.

Changed August 30, 2011 03:36PM UTC by rwaldron comment:8

_comment0: @macrae_dj Please update to: http://code.jquery.com/jquery-1.6.3rc1.js and remove the "async: false" option, ping me here and I wil retest1314718726552456

@macrae_dj Please update to: http://code.jquery.com/jquery-1.6.3rc1.js and remove the "async: false" option, ping me here and I will retest

Changed August 30, 2011 03:46PM UTC by macrae_dj comment:9

Changed August 30, 2011 04:11PM UTC by rwaldron comment:10

Changed August 30, 2011 04:27PM UTC by macrae_dj comment:11

@rwaldron Thanks for testing this out. Appreciated.

Do you get the same result for both links (ajax_test2.html and ajax_test2b.html)?

Changed August 30, 2011 05:06PM UTC by rwaldron comment:12

_comment0: No, I did not. In the first file, the result I saw was that no error was reported - but that link is irrelevant because it uses an outdated version of the lib and an intentionally broken behaviour (async:false allows users to break the "asynchronous" design of XMLHttpRequest)1314724017430952

No, I did not. In the first file, the result I saw was that no error was reported (as your original filing states) - but that link is irrelevant because it uses an outdated version of the lib and an intentionally broken behaviour (async:false allows users to break the "asynchronous" design of XMLHttpRequest)

Changed August 30, 2011 05:45PM UTC by macrae_dj comment:13

_comment0: Good. \ However, I get no error message with either ajax_test or ajax_testb. \ \ I have experimented with Timmy's jsfiddler link and ... \ \ with async I get no error message, \ \ [http://www.alisonstrachan.co.uk/tests/ajax2/ajax2_async_true.jpg] \ \ with sync I do get the error message. \ \ [http://www.alisonstrachan.co.uk/tests/ajax2/ajax2_async_false.jpg] \ \ I.e. for me, the bug seems to be present with async operation (can you try this also and see what you get). \ \ It seems like the bug is intermittent/depends on other platform factors etc. Tricky. \ \ I'm a bit worried about what you say about the 'sync' behaviour. In my application, I need one ajax request to complete before the next one starts (its not a publicaly available web page, but a script I run locally). I can adjust my own javascript to accomplish this and use the async ajax. But that's not the issue, if a feature is available you should be able to use it or at the very least there should be some warnings about it! \ 1314727388477444

@rwaldron Good.

However, I get no error message with either ajax_test or ajax_testb.

I have experimented with Timmy's jsfiddle link and ...

with async I get no error message,

http://www.alisonstrachan.co.uk/tests/ajax2/ajax2_async_true.jpg

with sync I do get the error message.

http://www.alisonstrachan.co.uk/tests/ajax2/ajax2_async_false.jpg

I.e. for me, the bug seems to be present with async operation (can you try this also and see what you get).

It seems like the bug is intermittent/depends on other platform factors etc. Tricky.

I'm a bit worried about what you say about the 'sync' behaviour. In my application, I need one ajax request to complete before the next one starts (its not a publicly available web page, but a script I run locally). I can adjust my own JavaScript to accomplish this and use the async ajax. But that's not the issue, if a feature is available you should be able to use it or at the very least there should be some warnings about it!

Changed August 30, 2011 06:54PM UTC by rwaldron comment:14

In my application, I need one ajax request to complete before the next one starts

Using async:false is the wrong approach, you should use the $.Deferred object returned by the first ajax call to schedule the next call in the queue. Resources:

The best resource is this presentation: http://vimeo.com/22687950

if a feature is available you should be able to use it or at the very least there should be some warnings about it!

You're right! Which is why it's documented here: http://api.jquery.com/jquery.ajax

>> async, Boolean

>> Default: true

>> By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.

Changed August 30, 2011 07:14PM UTC by macrae_dj comment:15

_comment0: \ > You're right! Which is why it's documented here: http://api.jquery.com/jquery.ajax \ > \ > >> async, Boolean \ > >> Default: true \ > >> By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. \ \ I read this and was OK with this. This is not a problem for me. This is not the problem we are experiencing here. \ \ Anyway back to the bug. I've tried it on Internet Explorer, and I get an error reported for both async and sync but the message pop-up is different for each. Does this help explain my Firefox is missing some errors... \ \ [http://www.alisonstrachan.co.uk/tests/ajax2/ajax2_async_true_ie.jpg] \ \ [http://www.alisonstrachan.co.uk/tests/ajax2/ajax2_async_false_ie.jpg] \ 1314731737654779
You're right! Which is why it's documented here: http://api.jquery.com/jquery.ajax >> async, Boolean >> Default: true >> By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.

I read this and was OK with this. This is not a problem for me. This is not the problem we are experiencing here.

Anyway back to the bug. I've tried it on Internet Explorer, and I get an error reported for both async and sync but the message pop-up is different for each. Does this help explain my Firefox is missing some errors...

http://www.alisonstrachan.co.uk/tests/ajax2/ajax2_async_true_ie.jpg

http://www.alisonstrachan.co.uk/tests/ajax2/ajax2_async_false_ie.jpg

Changed August 30, 2011 08:07PM UTC by rwaldron comment:16

No, it doesn't explain anything as there is nothing more to explain. Please redirect further questions to https://forum.jquery.com/using-jquery

Changed August 31, 2011 09:12AM UTC by macrae_dj comment:17

I give up