阿贾克斯形式不起作用使用Internet Explorer 8,9 [英] Ajax Form Does Not Work With Internet Explorer 8,9
问题描述
我用ajax写的一种形式,所以页面submittion后不会刷新。 在Chrome和Firefox它工作得很好,问题来了,当我使用Internet Explorer(到目前为止我只签8,9)。 在IE8,9我无法发送表单,点击提交按钮不会触发任何事件,因为它应该。 这里的code我使用,我想明确指出,我已经写在同一个文件中的PHP和AJAX code因为我的老板要求
I've written a form using ajax, so the page won't refresh after submittion. In Chrome and Firefox it works just fine, the problem comes up when I'm using Internet Explorer ( so far I've only checked 8,9). On IE8,9 I can't send the form , clicking on the submit button does not fire any event , as it should. Here's the code i'm using, I'd like to make clear that I've written the PHP and AJAX code in the same file due to my boss demands
if($_POST['isRadial']){
if(($_POST['redialVal']) && ($_POST['waitVal'])&& ($_POST['userId']) ){
$redial = $_POST['redialVal'] ;
$wait = $_POST['waitVal'];
$userId = $_POST['userId'];
$error_message = "123Could Not Save Settings, Please Try Again.";
$success_message ="Settings Were Updated Successfully, Will Be Implemented In 10 Minutes";
$query = mysql_query("....");
$getAll = mysql_query("...");
if(mysql_num_rows($getAll)>0){
$query = mysql_query("...'");
}
if(!$query){
echo $error_message;
return false;
}
else
echo $success_message;
//Update pull_tables
file_put_contents("....);
}
else
echo "</br>An Error Occured.Please Save Settings Again123.</br>";
}
阿贾克斯code:
Ajax code :
$(function(){
$('#submitRedialWait').click(function(){
var redial = $("#redialSettings").val();
var wait = $("#waitSettings").val();
//var userData = $("#ui").text();
var userData=<?php echo $IDuser; ?>;
$.ajax({
url: '' ,
type: 'POST',
data: {redialVal: redial , waitVal : wait, userId :userData, isRadial:"yes"},
success: function(result){
// $('#RedialWaitResults').text(result) ;
alert('settings have been saved.');
}
});
return false;
});
});
你有什么想法,有什么我的原因这个问题上来? (IE现有的除外)
Do you have any idea what my cause this problem come up ? (except of the existing of IE)
任何建议将是有益的, 在此先感谢
Any suggestion would be helpful , Thanks in advance
推荐答案
当我正与当作ajaxForm的文件提交异步,我发现2有趣的事情。
When I was working with AjaxForm for files submitting asynchronously, I found 2 interesting things.
第一,得到当作ajaxForm工作的跨浏览器(IE 7 +,Chrome浏览器,火狐)U必须确保使用提交当作ajaxForm的方法,你就像,即是这样的:
First, to get ajaxform to work cross browser (IE 7+, chrome, firefox) u got to make sure u're using the submit method of ajaxform, i.e. something like this:
$('form').ajaxForm({
success: ...,
error: ...
}).submit();
第二件事情让我感到惊讶。当作ajaxForm是工作无处不在,包括IE 7和9,但它不工作的IE 8的原因是这个,我忘了ATT的方法= POST。因此,U得确保u有这样的事情:
The second thing surprised me. AjaxForm was working everywhere, including IE 7 and 9, but it wasn't working on IE 8. The reason was this, I forgot the att method=POST. So, u gotta make sure u have something like this:
<form action="/action.php" method="POST">...
这篇关于阿贾克斯形式不起作用使用Internet Explorer 8,9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!