Internet Explorer 9不发布AJAX发布请求 [英] Internet Explorer 9 not posting AJAX post request
问题描述
我的JavaScript AJAX代码如下.这可以在Chrome和FF中按预期方式工作,但是在IE中,我发现POST变量从不将其置于下面的customer_savedesign.php
,但仍在控制台中提供了输出获得结果".我认为,如果我们在表单数据上使用jquery .serialize()
函数,则IE将正常工作,但仍无法正常工作.我也没有使用.submit()
,而是直接拨打了ajax调用.
My javascript AJAX code is below. This works as expected in Chrome and FF, but in IE, I've discovered the POST variables never make it to customer_savedesign.php
below, yet it still gives output "got result" in the console. I thought IE will work if we use the jquery .serialize()
function on form data, but it's still not working. I'm also not using .submit()
, just directly making an ajax call.
$.ajax({
type: "POST",
url: "customer_savedesign.php",
data: $('#designform').serialize(),
success: function(data)
{ arr = data.split(':');
console.log("got result");
// show response from the php script.
console.log("arr1 is " + arr[1]);
}
});
编辑
我的表单如下:
Edit
My form looks like this:
<div class='lefttable'>
<form id='designform' name='designform' method='post' action='customer_savedesign.php'>
<table style='margin-top:20px;text-align:right; bidi-direction:rtl; font-size:12pt' class='form' id='arabic-fields'>
<tr><td>اسم الشركة</td></tr>
<tr><td> <textarea tabindex="1" type='text' class='large ar arindic expand20-60' id='ar_Company_Name' style='bidi-direction:rtl; text-align:right;'></textarea> </td></tr>
<tr><td>رسالة الشركة</td></tr>
<tr><td> <textarea type='text' tabindex="1" class='large ar arindic expand20-60' id='ar_Company_Message' style='bidi-direction:rtl; text-align:right;'></textarea> </td></tr>
</table>
<input type='button' id='newfield' class='ar newfield' value='نص جديد' />
<input type='hidden' id='state_history' style='width:300px; height:30px;' />
<input type='hidden' id='current_state' style='width:300px; height:30px;' />
<input type='hidden' name='designid' id='designid' value='<?php echo $d->getID(); ?>' />
<input type='hidden' name='parentid' id='parentid' value='<?php echo $d->getParentID(); ?>'/>
<input type='hidden' name='productid' id='productid' value='0'/>
<input type='hidden' name='templateid' id='templateid' value='0'/>
<input type='hidden' name='orientation' id ='orientation' value='<?php echo $orientation; ?>' />
<input type='hidden' name='side' id='side' value='<?php echo $side; ?>' />
<input type='hidden' name='userid' id='userid' value='<?php echo $user_id; ?>'/>
<input type='hidden' name='usertype' id='usertype' value='<?php echo $user_type; ?>'/>
<input type='hidden' name='designdata' id='designdata' />
<input type='hidden' name='designtag' id='designtag' />
<input type='hidden' name='orderdetailid' id='orderdetailid' value='<?php echo $order_detail_id; ?>' />
<input type='hidden' name='wasnew' id='wasnew' value='<?php echo $wasnew; ?>' />
<input type='hidden' name='action' id='action' value='<?php echo $_GET['action']; ?>' />
<input type='hidden' name='saveasaction' id='saveasaction' />
</form>
</div>
推荐答案
尝试使用.serializaArray()而不是.serialize(). 另外,请勿在IE中使用console.log(),因为如果未打开控制台,它将失败.
try using .serializaArray() instead of .serialize(). Also, do not use console.log() in IE since it will fail if the console is not open.
这篇关于Internet Explorer 9不发布AJAX发布请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!