简体   繁体   中英

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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM