Barta Tamás
Barta Tamás

Reputation: 899

Can't get in the getJSON function()

I have getJSON code like this:

$('#selected_article').change(function(){
    $.getJSON('<?php echo $_SERVER['SCRIPT_NAME']; ?>', {
        ajax: 'ajax_article_partlist' ,
        parent_article: $('#selected_article').val()
    },

    function(data) {
        console.log(data);
    });
 });

I can't get the function(data). The console.log won't trigger an alert. On the PHP side I get stuff that I need; I can see it in the error_log, and I tried with print and also echo.

Upvotes: 2

Views: 159

Answers (1)

Viktor S.
Viktor S.

Reputation: 12815

In developer tools, see network tab. Once you run your ajax request - it should appear there. You can view what is returned. Looks like your response is not a valid JSON and that is why success calback is not called.

Upvotes: 2

Related Questions