0
我試圖用AJAX更新一個MySQL表與PHP變量。AJAX更新兩個PHP變量的Mysql表
這裏是我的回聲變量的PHP代碼:
<input type='button' name='button' class='bluebutton' value='Overnight Stay' onclick='callAjax($id1&$newName);' />
這裏是我的jQuery:
var xmlHttp
function callAjax(id) {
if (id.length==0) {
document.getElementById("txtHint").innerHTML=""
return
}
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) {
alert ("Browser does not support HTTP Request")
return
}
var url="gethint.php"
url=url+"?id="+id
url=url+"&name="+name
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject() {
var xmlHttp=null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e) {
// Internet Explorer
try {
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
這裏是gethint.php。現在我只是迴應變量。
$id = $_REQUEST['id'];
$name = $_REQUEST['name'];
echo $id;
echo $name;
,當我把它放在一起,我在其中規定控制檯得到一個對象預期的錯誤:
Message: Expected ')'
Line: 3
Char: 21
Code: 0
URI: ../scripts/clienthint.js
此錯誤對應於行「function callAjax(id)
」 我被困在愚蠢的我應該怎麼稱呼這一個。 我會很感激任何人都在關心的反饋,無論多麼重要。 再次感謝, --Matt
單獨的函數調用她與2個參數callAjax($ id1,$ newName) –