Ajax请求不到jsp?急!!!代码如下,改js所在页面和请求的jsp在同一目录下,找不出url啥问题,alert报404
varXMLHttpReq;functioncreateXMLHttpRequest(){if(window.XMLHttpRequest){//Mozilla浏览器XM...
var XMLHttpReq;
function createXMLHttpRequest() {
if(window.XMLHttpRequest) { //Mozilla 浏览器
XMLHttpReq = new XMLHttpRequest();
}else if (window.ActiveXObject) { // IE浏览器
try {
XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
}
function getJobs(companyId){
var url = "getJobList.jsp?companyId="+companyId;
createXMLHttpRequest();
if(XMLHttpReq!=null){
XMLHttpReq.open("GET",url,true);
XMLHttpReq.onreadystatechange = complete;
XMLHttpReq.send(null);
}
}
function complete(){
if (XMLHttpReq.readyState == 4)
{
alert(XMLHttpReq.status);
if (XMLHttpReq.status == 200){
var result = XMLHttpReq.responseText;
}
}
}
必须是ajax 展开
function createXMLHttpRequest() {
if(window.XMLHttpRequest) { //Mozilla 浏览器
XMLHttpReq = new XMLHttpRequest();
}else if (window.ActiveXObject) { // IE浏览器
try {
XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
}
function getJobs(companyId){
var url = "getJobList.jsp?companyId="+companyId;
createXMLHttpRequest();
if(XMLHttpReq!=null){
XMLHttpReq.open("GET",url,true);
XMLHttpReq.onreadystatechange = complete;
XMLHttpReq.send(null);
}
}
function complete(){
if (XMLHttpReq.readyState == 4)
{
alert(XMLHttpReq.status);
if (XMLHttpReq.status == 200){
var result = XMLHttpReq.responseText;
}
}
}
必须是ajax 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询