jQuery.post form submit odd bug firefox only

1.5k Views Asked by At

I've search high and low for an answer to this but unfortunately I'm stuck. The problem is only occuring in Firefox (tested IE, Chrome and Safari also - works fine, no errors of any sort). I'll detail the sequence of events to save posting all my code.

  1. ASP.NET MVC 3 application, basic form loads into a jQuery UI dialog
  2. Custom jQuery to hijax the form submit (serialize the form and then $.post to the server - no compiler errors when debugging and post shows up in Firebug without errors)
  3. Http GET (automatically happens) getting the response object from the server (+ success text and XHR), response is plain HTML in this case (again, shows up in Firebug with no errors)
  4. Custom jQuery to change the HTML of the UI dialog from it's current HTML to the response Html - this is where it fails.

I've used javascript alerts to debug the sequence of events and as soon as the post (and get) is complete, everything just... sort of stops.

As I say, only in firefox! Very odd, just wondering if there's any known bugs with ajax and firefox or anybody has heard of a similar situation?

I must also add, that on other parts of my site, this works perfectly in all browsers! The only difference between this form and the other forms that do successfully complete the function is that the response from this form is the same "page" again but updated rather than a new "page". (I use "page" as I got all this working with Javascript turned off first and for graceful degredation)

HELP! Or laugh, either is fine.

UPDATE

I have tried sending a view with a blank model back as the action result - works in every browser except firefox - firefox retains the values from the previous post! And then I got to thinking - that's a trait of firefox isn't it? And maybe that's why the original "re-direct" html response doesn't work?? I think it's time to give up and let people know they can't use Firefox for that particular function!

2

There are 2 best solutions below

0
On BEST ANSWER

Ok so I'm answering my own question.

The only way I found to get round it is to use $.ajax instead of $.post and to use the option async : false

Hope this helps somebody.

Rob

1
On

Have you tried adding the attribute [OutputCache(Location = System.Web.UI.OutputCacheLocation.None)] to your Action for your GET? It sounds to me like a caching issue.