0
任何人都願意幫我解決這個腳本嗎?AJAX to JQuery Conversion Assistance
我只需要有人把這個片段的AJAX,基本上用jQuery重新編程,所以我可以學習它,並學習更多關於如何使用jQuery。這是我目前正在使用的AJAX工作原理,我認爲如果我能在jQuery中看到它,它會啓動我的學習過程...
因此,如果任何人都會如此善良,這是腳本:
function CreateXmlHttpObject() { //function to return the xml http object
var xmlhttp = false;
try {
xmlhttp = new XMLHttpRequest(); //creates a new ajax object
} catch(e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //this is for IE browser
} catch(e) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP"); //this is for IE browser
} catch(e1) {
xmlhttp = false; //error creating object
}
}
}
return xmlhttp;
}
function getMetaID(strURL) {
var req = CreateXmlHttpObject(); // function to get xmlhttp object
if(req) {
req.onreadystatechange = function() {
if(req.readyState == 4) { //data is retrieved from server
if(req.status == 200) { // which reprents ok status
document.getElementById('meta_id').innerHTML = req.responseText; //put the results of the requests in or element
} else {
alert("There was a problem while using XMLHTTP:\n");
}
}
}
req.open("GET", strURL, true); //open url using get method
req.send(null); //send the results
}
}
這是調用函數(PHP)的網頁上:
echo '<select name="meta_id" onChange="getMetaID('."'".'http://www.mysite.com/backoffice/meta_tags/ajaxpageid.php?meta_id='."'".'+this.value)">';
這之後,一個<div>
。
希望這是足夠的信息,讓它有意義。當然,我感謝所有幫助...