views:

43

answers:

2

Guys i have a little problem when i submit my form the page gets redirected to the result, instead of staying on the same page. On the server-side i have a PHP that spits an simple status codes like this:

echo '<span>Success/Error</span>';
exit;

and this is my request:

 jQuery.ajax({
  type: "POST",
  url: "ajax.php",
  data: dataString,
  success: function() {
   alert('Transmitted, but no result');
  },
  error: function() {
   alert('NOT sended');
  }
 });

the form itself its simple:

echo '<form method="POST" enctype="multipart/form-data">';

And btw can someone help me out why the success/error functions are not called?

A: 

Remove the method from the form tag

elementvine
1. The attribute is required. 2. Removing it would just cause the form to submit to the current URI as browsers error recover. 3. The question clearly shows that it is missing already.
David Dorward
No actually its not missing its there, i tried without it and as you say its transformed to a GET request.
Anonymous
The browser treats request from the HTML form and JS XHT request as two separate entities, which is correct. If you're sending an ajax request as post with dataString variables, the html form element has NOTHING to do with this.
Okay what can i do to fix this? I mean now i try serializing the data for the POST request.
Anonymous
A: 

You wanted to use this.