1

私は次のものを持っています:

クライアント側には、次のものがあります。

for (var i = 0; i < myArray1.length; i++) 
{
  var dat = encodeURIComponent(document.getElementById(myArray1[i]).value);
  var obj = {
             id:myArray1[i],
             val:dat
            };
  jsonObj.push(obj);

}

$.ajax({
        type: "POST",
        url: "example/example.php?id="+id+"&ps="+ps+"&json="+JSON.stringify(jsonObj),
        success: function(data){
        alert('Request Complete');
        failure: function(errMsg) {
        alert('Your Request Could Not Be Completed - error:3');
        }
      });

これは、PHPスクリプト(example.php)で機能します。次のものがあります。

    $url = "http://TheOtherServer/example2.php?
            func=12&id=".$_GET['id']."&ps=".$_GET['ps'];

    $content = $_GET['json'];
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER,
            array("Content-type: application/json"));
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

    $json_response = curl_exec($curl);

    $status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

    curl_close($curl);

    $response = json_decode($json_response, true);
    if ( $status == 200 && $response == '01') {
        echo '01';
    }
    else
    {
        echo $response;
    }

$_GET json を error_log すると正しいので、これらは正しいようです。他のサーバー(example2.php)で私は持っています

 $json = (json_decode(file_get_contents("php://input")));

これは空の値を返します。誰かが私が間違っている場所を見ることができますか?

4

0 に答える 0