简体   繁体   English

jQuery Ajax重定向

[英]jQuery ajax redirect

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: 在服务器端,我有一个PHP,它会吐出一个简单的状态代码,如下所示:

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? 顺便说一句,有人可以帮助我为什么不调用成功/错误功能吗?

您想使用这个

从表单标签中删除方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM