WordPress ajax not returning the result

I’m using the below code for one of my simple work in wordpress plugins.

    $j = jQuery.noConflict();
    $j(document).ready(function(){

    $j.ajax({
    url:"/wp-admin/admin-ajax.php",
    type:"POST",
    data:'action=market_place_posting_display&page='+ page1,
    success:function(data){$j('#mine').html(data);}
    });

    });

The thing is task is working properly but it’s not displaying the echo statment . If i do any insert or delete or what ever operations it’s doing. But when i try to print the data through the success message it’s not displaying! Could any one can guide me , what’s the problem here? If i do the same thing normally without wordpress it’s working perfectly.

Related posts

Leave a Reply

2 comments

  1. what are you doing in that “data” part ?? OMG!!! grave mistake!!

    you should pass real values in the data or
    remove data and encode the url yourself and put it in the url.

    $j = jQuery.noConflict();
        $j(document).ready(function(){
    
        $j.ajax({
        url:"/wp-admin/admin-ajax.php?action=market_place_posting_display&page="+ page1,
        type:"POST",
    
        success:function(data){$j('#mine').html(data);}
        });
    
  2. $j = jQuery.noConflict();
    $j(document).ready(function(){
    
    $j.ajax({
    url:"<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
    type:"POST",
    data:'action=market_place_posting_display&page='+ page1,
    success:function(data){$j('#mine').html(data);}
    });
    
    });
    

    The tag bloginfo(‘wpurl’); was missing!