javascript - Array not passing with ajax. -


This is a Java code code for AJAX calls. In this case, get the code variable AC program code and pass it on the compiler.php page.

() {var code = Document.getElementById ("file_cont") value; Var arr = New array (code, "c"); Warning (arrival [0]); Var xmlhttp; If (window.XMLHttpRequest) {xmlhttp = new XMLHttpRequest (); } And {xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP"); } Xmlhttp.onreadystatechange = function () {if (xmlhttp.readystate == 4 & xmlhttp.status == 200} {//window.location.assign("login.php "); Warning (xmlhttp.responseText); }} Xmlhttp.open ("POST", "server_controlers / compiler.php? Q =" + JSON.stringify (arr), true); xmlhttp.send ();}

Ajax call works well but the case is in php file. I am decoding the Jason array for the $ arr variable but if I echo this way < Code> echo $ arr [0] This is empty but if I type the code for the array in the Java script like var arr = new array ("aaa", " C ") in I do not get it; Its working fine Some can tell me that when I send the array with the code variable then what is wrong? This is a php file.

   

  server_controlers / compiler.php? Q = "+ JSON.stringify (AR)  

Your data is not being made secure URL. You say that there is c in the code, it means That is, in this case (for example) the & Amp; character that breaks the string string format and JSON will be invalid if it is removed from it.

encodeurIComponent to run it is in your URL.

server_controlers / compiler.php? Q = "+ encodeurIComponent (JSON.stringify (arr))

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -