2 回答

TA貢獻1836條經驗 獲得超5個贊
對呀對呀對呀,自己寫ajax唄。
jquery的也是js原生的ajax對象封裝的啊。
要是不會寫,偶送你一個
var xmlHttp;
//創建ajax請求的對象
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
elseif (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
//回調函數
var okFunc = function(){
if(xmlHttp.readyState == 4) {
if(xmlHttp.status == 200) {
//$("#msg").html(xmlHttp.responseText);
}
}
}
var startAjax = function(){
createXMLHttpRequest();
if( !xmlHttp){
return alert('create failed');
}
xmlHttp.open("POST", "Test", true);
xmlHttp.onreadystatechange = okFunc;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(document);
}
- 2 回答
- 0 關注
- 186 瀏覽
添加回答
舉報