0
我有一個頁面上的表單接受'ID',用戶輸入ID例如; 1026
表單提交到同一頁面ajax抓取該ID與其他網站進行覈對。如果響應不是404錯誤並且$ _GET爲真,我需要能夠讓表單發佈。
繼承人我有什麼
<script>
$(document).ready(function(){
$('form#getid').submit(function(){
var theid = $('input#id').val();
var dataString = "id=" + theid;
$.ajax({
type: "POST",
data: dataString,
success: function(response, status, xhr){
if(status=="success") {
$("#err-404").html(response);
}
else { alert(status+ ' - '+ xhr.status); }
}
}
});
});
return false;
});
</script>
我的形式
<form id="getid" action="">
<input type="text" name="id" />
<input type="submit" class="button" value="Go">
<div class="error" id="err-404"></div>
我認爲正確的軌道上IM,只是不知道如何把它放在一起。