use*_*316 2 javascript php ajax jquery
这是我的代码.如果我从php端收到的消息为0(发生错误),我想阻止表单提交.如果收到的消息是1,我想提交表格.
$(document).ready(function(){
$('#form').submit(function(e){
register();
});
});
function register(){
$.ajax({
type:"POST",
url:"submit.php",
data: $('#form').serialize(),
dataType: "json",
success: function(msg){
if(parseInt(msg)==1){
window.location=msg;
}
else if(parseInt(msg)==0){
$('#error_out').html(msg);
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3680 次 |
最近记录: |