joNathanBriG Posted September 23, 2014 Share Posted September 23, 2014 So I have an AJAX call that I'm using to POST 1 variable to a PHP script I have on a separate server. The PHP takes this variable and returns data based off of what the variable is. This works on all browsers except IE9 and below. IE9 returns data but it's an error saying the variable is missing which to me shows that it isn't sending the data. Below I have the AJAX call I'm making: (function (jQ) {var inviteID = '00000000000';jQ.ajax({url: 'www.example.com/test.php',type: 'POST',dataType: 'json',cache: false,data: { classID: inviteID },error: function (data, status, error) {jQ('.statusField').append('Failure: ' + data + status + error);},success: function (data, status, error) {jQ('.statusField').append('Success: ' + data);}}); })(jQuery); And below I have the PHP script that's being used: <?php//first POST to grab tokenfunction runPost($classID) {$postdata = array('username' => 'username','password' => 'password');//open connection$ch = curl_init();//set the url, POST datacurl_setopt($ch, CURLOPT_URL, "https://www.example.com/login");curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postdata));curl_setopt($ch, CURLOPT_USERAGENT, 'example');curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//execute post$result = curl_exec($ch);//close connectioncurl_close($ch);list($message, $time, $token, $userID) = split(',', $result);list($one, $two, $three, $four, $five) = split('\"', $token);$four = json_encode($four);$four = str_replace('"','',$four);$secondaryPostData = array('token' => $four,'data' => array( 'invitationID' => $classID));//open connection$chu = curl_init();//set the url, POST datacurl_setopt($chu, CURLOPT_URL, "https://www.example.com/classID");curl_setopt($chu, CURLOPT_POST, 1);curl_setopt($chu, CURLOPT_POSTFIELDS, json_encode($secondaryPostData));curl_setopt($chu, CURLOPT_USERAGENT, 'example');curl_setopt($chu, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));curl_setopt($chu, CURLOPT_RETURNTRANSFER, 1);//execute post$secondResult = curl_exec($chu);//close connectioncurl_close($chu);return json_encode($secondResult);}//Grab classID from javascriptecho runPost(trim($_POST['classID']));?> Again, this works fine in everything except IE. I've tried using just $.post and even XDomainRequest() and get the same result. The network console in IE shows that the Request body does have the classID in it, but I'm guessing it's just not sending the data to the PHP script. I don't know if I'm missing something that IE needs to send this to the PHP script but any help with this would be GREATLY appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/291235-ajax-not-posting-data-to-php-in-ie9/ Share on other sites More sharing options...
CroNiX Posted September 23, 2014 Share Posted September 23, 2014 What version of jQuery? Quote Link to comment https://forums.phpfreaks.com/topic/291235-ajax-not-posting-data-to-php-in-ie9/#findComment-1491879 Share on other sites More sharing options...
joNathanBriG Posted September 23, 2014 Author Share Posted September 23, 2014 I'm using 1.11.0 Quote Link to comment https://forums.phpfreaks.com/topic/291235-ajax-not-posting-data-to-php-in-ie9/#findComment-1491889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.