ajax发送不出去请求信息,求解决!!!!! 50
functioncreateAjax(){varrequest=false;if(window.XMLHttpRequest){request=newXMLHttpReq...
function createAjax(){
var request=false;
if(window.XMLHttpRequest){
request=new XMLHttpRequest();
if(request.overrideMimeType){
request.overrideMimeType("text/xml");
}
}else if(window.ActiveXObiect){
var versions=['Microsoft.XMLHTTP','MSXML.XMLHTTP','Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0',
'Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP.2.0'];
for(var i=0;i<versions.length;i++){
try{
request=new ActiveXObject(versions[i]);
if(request){
return request;
}
}catch(e){
request=false;
}
}
}
return request;
}
就是用post发送请求时,总是返回一些标签代码,而不是文本 展开
var request=false;
if(window.XMLHttpRequest){
request=new XMLHttpRequest();
if(request.overrideMimeType){
request.overrideMimeType("text/xml");
}
}else if(window.ActiveXObiect){
var versions=['Microsoft.XMLHTTP','MSXML.XMLHTTP','Msxml2.XMLHTTP.7.0','Msxml2.XMLHTTP.6.0',
'Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP.2.0'];
for(var i=0;i<versions.length;i++){
try{
request=new ActiveXObject(versions[i]);
if(request){
return request;
}
}catch(e){
request=false;
}
}
}
return request;
}
就是用post发送请求时,总是返回一些标签代码,而不是文本 展开
2个回答
展开全部
同志,既然有jquery为什么还要用原生的JS写这么多的代码呢?使用jquery.ajax,如下,
先引入jquery文件后,
$.ajax({
url: "ajax.ashx",
type: "POST", //POST提交
contentType:"application/x-www-form-urlencoded",
data: { ksbh: $("#ksbh").val() }, //传递到后台的,用JSON格式
beforeSend: function () {
$("#btnSubmit").val("正在提交中..."); $("#btnSubmit").attr("disabled","disabled")
},
complete: function () { $("#btnSubmit").val("提交"); $("#btnSubmit").removeAttr("disabled") },
success: function (data) {
$("#msg").html(data);
}
});
先引入jquery文件后,
$.ajax({
url: "ajax.ashx",
type: "POST", //POST提交
contentType:"application/x-www-form-urlencoded",
data: { ksbh: $("#ksbh").val() }, //传递到后台的,用JSON格式
beforeSend: function () {
$("#btnSubmit").val("正在提交中..."); $("#btnSubmit").attr("disabled","disabled")
},
complete: function () { $("#btnSubmit").val("提交"); $("#btnSubmit").removeAttr("disabled") },
success: function (data) {
$("#msg").html(data);
}
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询