我正在通過jQuery發送數據。我的等價代碼是...通過jquery發送數據時出現問題
$('#pcpmnum').blur(function(){
//alert("HIiiiiii");
var pcpmnum = $("#pcpmnum").val();
if(pcpmnum === "" | pcpmnum === null)
{
alert("Please Enter Mobile Number");
}
else
{
alert(pcpmnum);
$.post("searchpcp.php", {cntctnumber: "+pcpmnum+"}, function(){
alert("Success");
}
}
});
我的php文件我簡單地使用過。
echo "HIIII";
這個$ .post函數是否相當於Ajax函數?
.post的$是$ .ajax的快捷方式,因此您不必填寫儘可能多的選項。 –
'$ .post'是'$ .ajax'的縮寫,帶有某些預設(http://api.jquery.com/jQuery.post)。從代碼中它應該正確地調用'searchpcp.php',但爲什麼你將'pcpmnum'作爲一個字符串傳遞,而不是傳遞它的值(沒有引號和+ es)? – m90