表单提交的Ajax代码仍然刷新页面

时间:2016-12-12 06:28:26

标签: ajax

这是我的ajax代码..我不知道我做错了什么。问题是即使我有这个代码,页面仍然在提交表单后刷新。

if(data["scenario"]==1){
     1;
     }
     else{
      0;
       }

1 个答案:

答案 0 :(得分:0)

试试吧......

$.ajax({
  type: 'POST',
  url: 'registeruser.php',
  data: formData,
  datatype: 'json',
  encode: true,
success: function(data){
alert('registerd successfully');
}
});



event.preventDefault();
相关问题