我有一个HTML,我想在它被提交之前验证它,并且我在验证中使用了ajax,我希望它在ajax结果为“OK”时提交表单并显示警告if else ,结果肯定是“OK”,但它没有提交表格,请帮助!!
这是我使用的HTML代码
Planer Name | Title | Month Choose 1 2 3 4 5 6 7 8 9 10 11 12 Week Choose 1 2 3 4 |
Submition Date
这是js,我已经在页面的头部链接了jquery
JS
function validateplan(){
var title = $("#title").val();
var month = $("#week").val();
var subdate = $("#subdate").val();
var week = $("#week").val();
$.ajax({
url: 'ajax/plan_validate.php',
data: {title: title,month: month,subdate: subdate,week: week},
success: function(data){
if (data == 'OK'){
alert("We are OK so far");
return true;
}
else
{
alert(data);
}
},
error: function(){
alert("There is something wrong");
}
});
return false;
}