Ajax代码控制

时间:2011-10-06 21:29:15

标签: javascript ajax forms

很抱歉这个愚蠢的问题,但是,这段代码是正确的,因为它似乎已被打破。

var request_type; 
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
    request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
    request_type = new XMLHttpRequest();
}
return request_type;
}

var http = createObject();

var nocache = 0;
function vloz() {

var kom= encodeURI(document.getElementById('komen').value);
var site_name = encodeURI(document.getElementById('user_id').value);
var p_id = encodeURI(document.getElementById('p_id').value);
var zed = encodeURI(document.getElementById('zed').value);

nocache = Math.random();
http.open('get', 'kmnt.php?site_url='+kom+'&site_name=' +site_name+'&site='+p_id+'&    zed='+zed+'&nocache = '+nocache);
http.onreadystatechange = insertReply;
http.send(null);
}
function insertReply() {
    if(http.readyState == 4){
    }
}

当我发送komen,user_id,p_id和zed

时,我有一个表单

1 个答案:

答案 0 :(得分:0)

不确定是不是这样但是你的代码开头似乎有太多花括号:

if(browser == "Microsoft Internet Explorer") {
    request_type = new ActiveXObject("Microsoft.XMLHTTP");
} else {
    request_type = new XMLHttpRequest();
}
return request_type;

// }   <- extra one here