user800014
user800014

Reputation:

Why using jquery's submit with server 302 code redirect to wrong url in internet explorer?

I have a form that will perform some validations before submitting the data, so I bind this validation in the click event of the submit button.

$('#myButton').click(function(e){
  e.preventDefault();
  e.returnValue = false;
  //perform validations...
  if(valid) {
    $('#theForm').submit();
  }
});

Nothing magic so far. If everything is ok in the server side, the page will return an 302 http status code.

In Firefox and Chrome, the url is successfully redirected, but in Internet Explorer 8 (not tested in another version) this causes to the browser redirect to the same url.

If I remove the javascript code, IE redirect's correctly.

So, my question is, what's the submit() of JQuery's have different from the normal html submit?

Upvotes: 0

Views: 760

Answers (1)

Kevin B
Kevin B

Reputation: 95023

I'm not sure what the difference is, but you should be able to trigger the form's submit event directly with this, effectively bypassing jQuery's submit event handling.:

$("#theform")[0].submit();

If the same thing happens, then the problem is not with jQuery and is more than likely a cross-browser issue instead.

Upvotes: 1

Related Questions