Don*_*Msc 1 javascript php mysql ajax
在AJAX网站上工作(HTML,CSS,JavaScript,AJAX,PHP,MySQL).我有多个javascript函数,它们从mysql中获取行,将它们包装在html标记中,并将它们嵌入到HTML中(通常使用AJAX).
问题:
一切都工作得很完美,除非我用Firefox运行网站(一次不是InternetExplorer导致麻烦).
该站点目前处于开发阶段,因此其脱机,但运行在localhost(WampServer,apache,Windows XP SP3,VISTA,7)上.
所有其他跨浏览器冲突已被删除,并且在所有主要浏览器(包括IE,Chrome,Opera和Safari)上都能完美运行,但如果浏览器是Firefox,我绝对不会从HTTPRequest(AJAX)中获得任何信息.
所有浏览器都有最新版本.
代码:
我有一系列的javascript函数,所有这些函数的结构如下:
function getDatay(){
var a = document.getElementById( 'item' ).innerHTML;
var ajaxRequest;
try{//Browser Support Code:
// code for IE7+, Firefox, Chrome, Opera, Safari:
ajaxRequest = new XMLHttpRequest();
} catch (e){
// code for IE6, IE5:
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser is not compatible - Browser Incompatibility Issue.");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState < 4){
document.getElementById( 'theDiv' ).innerHTML = 'LOADING...';
}
if(ajaxRequest.readyState == 4){
document.getElementById( 'theDiv' ).innerHTML = ajaxRequest.responseText;
}
}
//Post vars to PHP Script and wait for response:
var url="01_retrieve_data_7.php";
url=url+"?a="+a;
ajaxRequest.open("POST", url, false);//must be false here to wait for ajaxRequest to complete.
ajaxRequest.send(null);
}
Run Code Online (Sandbox Code Playgroud)
我的钱是最后五行代码导致问题的原因.
任何有关如何让Firefox和AJAX协同工作的建议都是最受欢迎的......
不得不发布那堆代码翻译成的jquery one-liner!
$("#theDiv").text("LOADING...").load("01_retrieve_data_7.php?a="+$("#item").text());
Run Code Online (Sandbox Code Playgroud)