Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery Requested JSON parse failed when parsing $get argument
    primarykey
    data
    text
    <p>Jquery has is working before the following line is changed</p> <pre><code>data: "ID=1", $ID=$_GET["ID"] $array=array("$ID",'B',"C"); </code></pre> <p>from </p> <pre><code>data: "", $array=array('A','B',"C"); </code></pre> <p>my ajax file</p> <pre><code>&lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt; &lt;button class="ajax_action"&gt;click&lt;/button&gt; &lt;script&gt; $('button.ajax_action').on('click', function (e) { e.preventDefault(); var target = $(this); $.ajax({ url: "test.php", data: "ID=1", type: 'POST', dataType: 'json', success: function (data) { var name=data[0]; target.html(name); target.attr('disabled', 'disabled') }, error: function(jqXHR, exception) { if (jqXHR.status === 0) { alert('Not connect.\n Verify Network.'); } else if (jqXHR.status == 404) { alert('Requested page not found. [404]'); } else if (jqXHR.status == 500) { alert('Internal Server Error [500].'); } else if (exception === 'parsererror') { alert('Requested JSON parse failed.'); } else if (exception === 'timeout') { alert('Time out error.'); } else if (exception === 'abort') { alert('Ajax request aborted.'); } else { alert('Uncaught Error.\n' + jqXHR.responseText); } } }); }); &lt;/script&gt; </code></pre> <p>php file test.php (same dir with ajax file)</p> <pre><code>&lt;?php $ID=$_GET["ID"] $array=array("$ID",'B',"C"); echo json_encode($array); ?&gt; </code></pre> <p>How to make this work with $_GET["ID"], I need to do action according to the ID which is variable according to the product user chosen</p> <hr> <p>and I've read through manual, long ago however manual is ain't easy for a newcomer you know. "You should read manual, idiot" is the worst answer I've ever heard and I can answer every question I don't know with this sentence. @tereško</p> <p>further changed to following line but still ain't working, </p> <pre><code> data: {'ID':1}, type: 'POST', &lt;?php $ID=$_POST["ID"] $array=array("$ID",'B',"C"); echo json_encode($array); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload