Now i have the following script as base.js
function ExtConn()
{
this.getHTML = function(_url, querystring){
bodyContent = $.ajax({
url: _url,
type: 'POST',
data: querystring,
async:false
});
//alert(bodyContent);
return bodyContent.responseText;
};
this.sendForm = function(Form){
var dataString = '';
for(i=0; i<Form.length; i++){
var obj = Form;
if(!obj.disabled){
if(obj.getAttribute('type') == "radio" || obj.getAttribute('type') == "checkbox"){
if(obj.checked){
dataString += obj.name + "=" + obj.value + "&";
}
}else{
dataString += obj.name + "=" + obj.value + "&";
}
}
}
dataString = dataString.substring(0, dataString.length -1);
if($(Form).valid()){
$.ajax({
url: $(Form).getAttribute('action'),
type: 'POST',
data: dataString + "&do="+$(Form).getAttribute('do'),
beforeSend:function(xhr){
showLoading();
},
success: function(data) {
hideLoading();
data = $.trim(data);
if(data.indexOf("1")==0){
showDialog("", "Proses berjaya<br><span style='font-size:10px;'>Tetingkap akan tertutup sendiri. Sila tunggu.</span>");
setTimeout("$('#messagebox').dialog('close'); updateAreas();", 2000);
}else{
showDialog("", "Proses gagal<br><span style='font-size:10px;'><br>"+data);
}
}
});
}
return false;
};
}
and the following html as the test.html
<html>
<head><title>Test Ajax Form</title>
<script type="text/javascript" src="a/valid/path/to/jquery.min.js"></script>
<script type="text/javascript" src="base.js"></script>
<script type="text/javascript">
var page = new ExtConn();
</script>
</head>
<body>
<form action="res.php" method="post" onsubmit="return page.sendForm(this);" do="try">
<input type="text" id="testText" name="testText" value="" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
and here is the res.php
<?php
if(isset($_POST)){
die("1 OK");
}else{
die("0");
}
?>
My Question is - the above scripts run perfectly (i mean, form will not cause the page to navigate to the res.php page) in Mozilla and Google Chrome. But why it doesn't work with ie? why it did navigates to the res.php page?
Any help would be appreciated.
function ExtConn()
{
this.getHTML = function(_url, querystring){
bodyContent = $.ajax({
url: _url,
type: 'POST',
data: querystring,
async:false
});
//alert(bodyContent);
return bodyContent.responseText;
};
this.sendForm = function(Form){
var dataString = '';
for(i=0; i<Form.length; i++){
var obj = Form;
if(!obj.disabled){
if(obj.getAttribute('type') == "radio" || obj.getAttribute('type') == "checkbox"){
if(obj.checked){
dataString += obj.name + "=" + obj.value + "&";
}
}else{
dataString += obj.name + "=" + obj.value + "&";
}
}
}
dataString = dataString.substring(0, dataString.length -1);
if($(Form).valid()){
$.ajax({
url: $(Form).getAttribute('action'),
type: 'POST',
data: dataString + "&do="+$(Form).getAttribute('do'),
beforeSend:function(xhr){
showLoading();
},
success: function(data) {
hideLoading();
data = $.trim(data);
if(data.indexOf("1")==0){
showDialog("", "Proses berjaya<br><span style='font-size:10px;'>Tetingkap akan tertutup sendiri. Sila tunggu.</span>");
setTimeout("$('#messagebox').dialog('close'); updateAreas();", 2000);
}else{
showDialog("", "Proses gagal<br><span style='font-size:10px;'><br>"+data);
}
}
});
}
return false;
};
}
and the following html as the test.html
<html>
<head><title>Test Ajax Form</title>
<script type="text/javascript" src="a/valid/path/to/jquery.min.js"></script>
<script type="text/javascript" src="base.js"></script>
<script type="text/javascript">
var page = new ExtConn();
</script>
</head>
<body>
<form action="res.php" method="post" onsubmit="return page.sendForm(this);" do="try">
<input type="text" id="testText" name="testText" value="" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
and here is the res.php
<?php
if(isset($_POST)){
die("1 OK");
}else{
die("0");
}
?>
My Question is - the above scripts run perfectly (i mean, form will not cause the page to navigate to the res.php page) in Mozilla and Google Chrome. But why it doesn't work with ie? why it did navigates to the res.php page?
Any help would be appreciated.