1 回答

TA貢獻1802條經驗 獲得超4個贊
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | $(function (){ $("#submit").click(function (){ var username=$("#username").val() $.ajax({ type: "get", url:"post.asp", async: true, timeout: 15000, data:{username:username}, beforeSend: function(xhr) { //beforeSend定義全局變量 xhr.setRequestHeader("If-Modified-Since", "0"); //If-Modified-Since HTTP請求頭標簽,即比較瀏覽器緩存頁面時間 }, success: function(xmlDoc, textStatus, xhr) { if(xhr.readyState==4) { if(xhr.status == 200) { var str=xhr.responseText; //獲取返回值 if (str==0){ //查詢返回0表示已注冊 alert("已被注冊") return; } else{ //運行正確的代碼 alert("可以正常注冊") } } } }, }); }); }); |
- 1 回答
- 0 關注
- 498 瀏覽
添加回答
舉報