Internet Explorer 9 not posting AJAX post request

2019-08-28 03:02发布

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>

1条回答
贪生不怕死
2楼-- · 2019-08-28 03:23

try using .serializaArray() instead of .serialize(). Also, do not use console.log() in IE since it will fail if the console is not open.

查看更多
登录 后发表回答