Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I tried your function and it worked fine for me when I left out this line: <code>contentType: "application/json",</code> and when I added it in, I started getting a failed response of "0".</p> <p>In the <a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">manual</a>, it says to use this content type for most cases: <code>'application/x-www-form-urlencoded; charset=UTF-8'</code> (which is the default). So unless you have a good reason, I think you should remove that line.</p> <p>In the first function, it doesn't exist and you turned off 'json' dataType, so you are probably alerting a really nice looking string that <em>looks</em> like the data you want. If you make sure that you have <code>dataType: 'json'</code> and remove <code>contentType: application/json'</code>, you should be good to go.</p> <p><strong>EDIT</strong>: This is exactly what I used, and it worked great. Not sure what else to suggest. What is <code>datastr</code> in your js?</p> <pre><code>$.ajax({ url: 'dbtryout2_2.php', type: 'post', async: true, cache: false, dataType: 'json', success: function( response ) { // response is returned as json object: ["album1","album2","album3","album4","album5"] //console.log(response); if ( response ) { $.each(response, function (i, v) { alert(i + "--" + v); }); } }, error: function( xhr ) { console.log(xhr.responseText); } }); </code></pre> <p><strong>Note</strong>: If you have specified "dataType:'json'", you don't have to $.parseJSON, because the response is already returned as JSON.</p>
    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.
    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