그래서 별도의 서버에있는 PHP 스크립트에 POST 변수를 사용하는 AJAX 호출이 있습니다. PHP는이 변수를 취하여 변수가 무엇인지에 따라 데이터를 반환합니다. 이것은 IE9 이하를 제외한 모든 브라우저에서 작동합니다. IE9는 데이터를 반환하지만 데이터가 전송되지 않음을 나타내는 변수가 없다는 오류가 발생합니다. 내가 AJAX 호출 내가 만들고있어이 아래 :AJAX는 IE에서 PHP에 데이터를 게시하지 않습니다
<?php
//first POST to grab token
function runPost($classID) {
$postdata = array(
'username' => 'username',
'password' => 'password'
);
//open connection
$ch = curl_init();
//set the 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 the 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 from javascript
echo runPost(trim($_POST['classID']));
?>
는 다시,이 IE를 제외한 모든에서 잘 작동합니다
(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);
아래를 내가 사용되고있는 PHP 스크립트가 있습니다. 여러 가지 방법을 시도했지만 모든 것이 저에게 같은 오류를줍니다. IE의 네트워크 콘솔은 요청 본문에 classID가 있음을 보여 주지만 데이터를 PHP 스크립트로 보내지 않는 것으로 추측하고 있습니다. Internet Explorer가 PHP 스크립트로 보내야하는 내용이 누락되어 있는지 여부는 알 수 없지만이 문제에 대한 도움은 크게 감사하겠습니다.
다음으로 시도하십시오. data : { 'classID': inviteID}, – Julo0sS
IE 네트워크 콘솔에서 PHP 스크립트로부터 응답을 받고 있는지 확인하십시오. – James
classID 주위에 따옴표를 추가하지 못했습니다. 성공 : { "error": "required data [invitationID]", "code": 400} –