jquery - AJAX not posting data to PHP in IE only -
so have ajax call i'm using post 1 variable php script have on separate server. php takes variable , returns data based off of variable is. works on browsers except ie9 , below. ie9 returns data it's error saying variable missing me shows isn't sending data. below have 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 have php script that's being used:
<?php //first post grab token function runpost($classid) { $postdata = array( 'username' => 'username', 'password' => 'password' ); //open connection $ch = curl_init(); //set url, post data curl_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 connection curl_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 url, post data curl_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 connection curl_close($chu); return json_encode($secondresult); } //grab classid javascript echo runpost(trim($_post['classid'])); ?>
again, works fine in except ie. i've tried several different methods gives me same error. network console in ie shows request body have classid in it, i'm guessing it's not sending data php script. don't know if i'm missing ie needs send php script appreciated.
have tried using ?
$("button").click(function(){ $.post("demo_test.php",function(data,status){ alert("data: " + data + "\nstatus: " + status); }); });
works me in chrome , ie.
$.post()
short hand method $.ajax();
every thing in $.ajax();
when started having problem never used $.ajax();
unless had send formdata entire object off field inputs in form
Comments
Post a Comment