我的AJAX出现了这个问题,它在IE 9中不起作用,但它在Opera 8.0 +,Firefox,Safari,chrome上运行良好。所以我不明白为什么会出错。在这里,我把我的完整代码。任何人都可以帮助我吗?
<html>
<head>
<IMG src="karvy.jpg" ALT="image">
<LINK href="text1.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="ts_picker.js"></script>
<script>
function fetch_javaScript(fund, agent, fromDate, toDate) {
var ajaxRequest; // The variable that makes Ajax possible!
if (window.XMLHttpRequest) { //Opera 8.0+, Firefox, Safari
ajaxRequest = new window.XMLHttpRequest();
} else {
try {
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP.6.0");
} catch (e) {
}
try {
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP.3.0");
} catch (e) {
}
try {
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
}
throw new Error("This browser does not support XMLHttpRequest.");
}
// Create a function that will receive data
// sent from the server and will update
// div section in the same page.
function handler() {
if (ajaxRequest.readyState == 4 && ajaxRequest.status == 200) {
document.getElementById("ajaxDiv").innerHTML = ajaxRequest.responseText;
}
}
function get_selected_data(o) {
var selectedOptions = [];
for ( var i = 0; i < o.options.length; i++) {
if (o.options[i].selected) {
selectedOptions.push('"' + o.options[i].value + '"');
}
}
if (selectedOptions.length) {
return '[]=[' + selectedOptions.join(',') + ']';
} else {
return '';
}
}
// var fund = document.getElementById('fund').value;
// var agent = document.getElementById('agent').value;
var fromDate = document.getElementById('fromDate').value;
var toDate = document.getElementById('toDate').value;
var queryString = "?fund="
+ get_selected_data(document.getElementById('fund'));
queryString += "&agent="
+ get_selected_data(document.getElementById('agent'));
queryString += "&fromDate=" + fromDate;
queryString += "&toDate=" + toDate;
if (ajaxRequest != null) {
ajaxRequest.open("GET", "final_ajax.pl" + queryString, true);
ajaxRequest.onreadystatechange = handler;
//console.log(queryObj.fund);
ajaxRequest.send(null);
} else {
window.console.log("AJAX (XMLHTTP) not supported.");
}
}
</script>
</head>
<body>
<form action="" name="tstest">
<table>
<thead>
<tr>
<th colspan="2">
<h1>MFS CALL RECORDINGS</h1>
</th>
</tr>
</thead>
<tr>
<td>
<h2>Funds</h2>
</td>
<td>
<select name="Funds" id=fund multiple>
<option value="Select">Select</option>
<option value="PMF">Principal</option>
<option value="PRAMERICA">Pramerica</option>
<option value="JM">JM</option>
<option value="DHL">DHL</option>
<option value="EMF">Edelweiss MF</option>
<option value="MORGAN">Morgan</option>
<option value="DAIWA">Daiwa</option>
<option value="TAURUS">Taurus</option>
<option value="AXIS">AXIS</option>
<option value="BPMF">BPMF</option>
<option value="PLMF">Peerless MF</option>
<option value="LIC NOMURA">LIC NOMURA</option>
<option value="PNB">PNB</option>
</select>
<br>
</td>
</tr>
<tr>
<td>
<h2>Agents</h2>
</td>
<td>
<select name="Agents" id="agent" multiple>
<option value="Select">Select</option>
<option value="Gyanesh">Gyanesh</option>
<option value="Satish">Satish</option>
<option value="Sailesh">Sailesh</option>
<option value="ArchanaMuluguru">Archana</option>
<option value="Santosh">Santosh</option>
<option value="Afreen">Afreen</option>
<option value="Salman">Salman</option>
<option value="Balaji">Balaji</option>
<option value="Priyanka">Priyanka</option>
<option value="KavithaGolla">Kavitha</option>
<option value="Rajvardhan">Rajvardhan</option>
<option value="Srinivasp">Srinivasp</option>
<option value="Surekha">Surekha</option>
<option value="Mazhar">Mazhar</option>
<option value="Pneeraja">Pneeraja</option>
<option value="Samiullah">Samiullah</option>
<option value="Nisar">Nisar</option>
<option value="Kareem">Kareem</option>
<option value="Shesherao">Shesherao</option>
<option value="KuttiSirisha">KuttiSirisha</option>
<option value="Sunitha">Sunitha</option>
<option value="Pavanir">Pavanir</option>
<option value="Divyav">Divyav</option>
<option value="Leela">Leela</option>
<option value="Avinash">Avinash</option>
<option value="BHARATI">Bharati</option>
<option value="Anil">Anil</option>
<option value="Sravan">Sravan</option>
<option value="Sudhakar">Sudhakar</option>
<option value="Madan">Madan</option>
<option value="Raghu">Raghu</option>
<option value="Rahul">Rahul</option>
<option value="Srinivas B">Srinivas B</option>
<option value="Akhilesh">Akhilesh</option>
</select>
</td>
</tr>
<tr>
<td>
<h2>From Date</h2>
</td>
<td>
<input type="Text" name="timestamp" id="fromDate" value="">
<a href="javascript:show_calendar('document.tstest.timestamp', document.tstest.timestamp.value);">
<img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp">
</a>
</td>
</tr>
<tr>
<td>
<h2>To Date</h2>
</td>
<td>
<input type="Text" name="timestamp1" id="toDate" value="">
<a href="javascript:show_calendar('document.tstest.timestamp1', document.tstest.timestamp1.value);">
<img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the timestamp">
</a>
<input type="Button" id="val" value="Submit" align="middle" method="GET" onclick="fetch_javaScript()" />
</td>
</tr>
<tfoot>
<tr align="center">
</tr>
</tfoot>
</table>
</form>
<div id='ajaxDiv'>Your Result Will Display Here</div>
<body style="background-color: white;">
</body>
</body>
</html>
答案 0 :(得分:3)
问题源于IE中页面中缺少DOCTYPE
这会将页面丢弃到IE5兼容模式,例如怪癖模式。修复它只需像这样添加DOCTYPE
:
<!doctype html>
<html>
<head>
<IMG src="karvy.jpg" ALT="image">
<LINK href="text1.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="ts_picker.js"></script>
这将使您处于标准模式,它将像现代浏览器一样。