需要确保我的ajax脚本设置正确
ajax代码:需要确保我的ajax脚本设置正确,ajax,Ajax,ajax代码: try { xmlhttp = new XMLHttpRequest(); } catch(ee) { try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
try {
xmlhttp = new XMLHttpRequest();
}
catch(ee) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E) {
xmlhttp = false;
}
}
}
div_base = "";
valor = 0;
function abre(arquivo,metodo,div) {
div_base = div;
valor++;
xmlhttp.open(metodo,arquivo+"?valor="+valor);
xmlhttp.onreadystatechange=response
xmlhttp.send(null)
}
function response() {
nova_div = div_base;
document.getElementById(nova_div).innerHTML="<div>Loading...</div>"
if (xmlhttp.readyState==4) {
document.getElementById(nova_div).innerHTML=xmlhttp.responseText
}
}
试试{
xmlhttp=新的XMLHttpRequest();
}
捕获(ee){
试试{
xmlhttp=新的ActiveXObject(“Msxml2.xmlhttp”);
}
第(e)款{
试试{
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
第(E)款{
xmlhttp=false;
}
}
}
div_base=“”;
英勇=0;
函数abre(arquivo,metodo,div){
div_base=div;
英勇++;
xmlhttp.open(metodo,arquivo+“?valor=“+valor”);
xmlhttp.onreadystatechange=response
xmlhttp.send(空)
}
函数响应(){
nova_div=div_基地;
document.getElementById(nova_div).innerHTML=“正在加载…”
如果(xmlhttp.readyState==4){
document.getElementById(nova_div).innerHTML=xmlhttp.responseText
}
}
html代码:
<form>
<select name="menu" style="width:400px; height:25px;">
<option>Change Theme:</option>
<option></option>
<option onclick="javascript: abre('Chat_Themes/Default.html','GET','response2');">Default - Shadow Hunters</option>
<option onclick="javascript: abre('Chat_themes/Custom.html','GET','response2');">Custom - Shadow Hunters</option>
</select>
</form>
<br />
<div id="response2"></div>
更改主题:
默认-阴影猎人
自定义-暗影猎人
我将“div=responce”改为“div=responce2”,但没有更改顶部的ajax代码,我不确定是否必须更改ajax代码,或者我可以不更改ajax代码,它仍然可以正常工作,但如果只是google chrome被延迟,它在google chrome idk上不起作用,但在ff和ie中也可以正常工作,有什么想法吗?尝试缩进代码:您会发现Try-catch语句没有匹配的大括号。您也可以尝试Javascript验证服务,如,但应首先使用缩进
您可能想考虑使用已经具有跨浏览器Ajax能力的第三方库,如