数组未与ajax一起传递。

This is the java script code for ajax call. In this case code variable get a c program code and pass it to the compiler.php page.

function insert(){
        var code = document.getElementById("file_cont").value;
        var arr = new Array(code,"c");
        alert(arr[0]);
    var xmlhttp;
        if (window.XMLHttpRequest)
          {
          xmlhttp=new XMLHttpRequest();
          }
        else
          {
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          }

        xmlhttp.onreadystatechange=function(){          
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {
                //window.location.assign("login.php");
                alert (xmlhttp.responseText);
            }
      }
    xmlhttp.open("POST","server_controlers/compiler.php?q="+JSON.stringify(arr),true);
    xmlhttp.send();
}

Ajax call work well but the case is in php file. I'm decode the jason array to $arr variable. But if i echo like this echo $arr[0] it is empty. But if i not include the code to the array in the java script like this var arr = new Array("aaaa","c"); its works fine. Can some tell me what is the wrong when i send the array with code variable. This is the php file.

<?php
if(isset($_REQUEST["q"])){

    $arr = $_REQUEST["q"];
    $arr2 = json_decode($arr);

    echo $arr2[0];  
    /*$file = fopen("../temp_files/c/mmm.c","w");
    fwrite($file,"$arr[0]");
    fclose($file);
    shell_exec('gcc -ommm ../temp_files/c/mmm.c');
    system('mmm', $retval);*/
}else{

}

?>
server_controlers/compiler.php?q="+JSON.stringify(arr)

Your data is not being made URL safe. You say that it contains c code, this means it might include (for instance) the & character which would break the query string format and cause the JSON to be invalid when extracted from it.

You need to run the data through encodeURIComponent before putting it into your URL.

server_controlers/compiler.php?q=" + encodeURIComponent(JSON.stringify(arr))

I think the problem in ur request type POST/GET. U shuffled 2 request types in 1. Also how i can see u try to send get request? but in parameters u use type POST.

All information what u need about GET request u can find here.

Also u can try change ur php code too. If u need to use POST

 <?php
     if($_POST){
     print($_POST);
     }
?>

After u can do all u need with data array.