Sending multiple Ajax queries in sequence fails in chrome and Safari

I have an issue were I display a sequence of dialogue or AJAX results that feed from each other. For example. A user will click to send a message that fires an ajax call, a dialogue opens, user fill out the form and sends, dialogue is closed, form is submitted via AJAX, then another AJAX response will either open up a dialogue or redirect the user. This process displays the first dialogue in all browsers but shows an error for the second dialogue in Safari and Chrome. I'm 95% sure it was working find in all browsers. Now it seems to fail. The error function is fired and the browser will then open the URL that was used for the second AJAX request.

I am using jquery, PHP and javascript and I had it running from an eval(json) command. I have since reconstructed the code to return raw Javascript.

In any case the error is fired on the 'error' handler of the AJAX query. The errors returned are very uninformative. I understand that Chrome has a caching process but not sure how may effect this or if it exist in safari. In any case it appears that the second call the ajax fails in safari and chrome before the returned javascript is run. I believe it was working in all browsers before but I'm not so sure now. I've spent almost half a day on it hence I would appreciate some assistance. :D

The Javascript function used to run the AJAX call is as follows

function page(url){
            type: "POST",
            url: url,
            success : ajaxReturn,
            cache: false,
            dataType: 'script',
            error: function(result, status, err) {
                alert('HTTP ' + result.status + ' Error Encountered: ' + result.statusText);
                alert('status: '+status+' error: '+err);


function ajaxReturn(ret){   

This is the same code used on both of the AJAX calls. And in some instances (IE if an error is found in the form) the return code is virtually exactly the same. I have a system in place for all the dialogue, AJAX and associated process which has been working fine till now.

The messages that I get returned from the error handler are:

HTTP 0 Errpr Encountered: error




status:error error:

As outputted via the alert statement. Where is an empty dialogue. Hence due the fact that the same ajax functions are run and the same code is being returned Chrome and Safari are having issues with the second call. Irrespective of what is returned they are failing on the error handler and I have not idea why.


Ok so I found the issues. The content of the form within the dialogue was submitted via another AJAX call. Hence on the onsubmit handler in the from content was serialized via jquery and then send to the AJAX. The thing is that I had not included a return false after the AJAX call in the onsubmit handler. So for some reason on chrome and safari this would return an error status of 0 and then forward me on the page called via AJAX.

Any case return false fixed it. Sweet!

Need Your Help

CarrierWave Renaming the Original, when I only Specified to do so for Versions

ruby-on-rails ruby-on-rails-3.1 carrierwave

The ultimate goal is to be able to upload PDFs, have thumbnails created, and have them saved as PNGs. One thing I should mention is that many of the PDFs are multipage. I have a temporary work arou...

What Web Applications Do You Know Using Webhooks

web-services http webhooks

Description of how a webhook works from -

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.