Miko
Miko

Reputation: 2633

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.

Upvotes: 1

Views: 484

Answers (2)

Jepser Bernardino
Jepser Bernardino

Reputation: 1372

$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!

Upvotes: 0

Shrinath
Shrinath

Reputation: 8118

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);}
    });

Upvotes: 2

Related Questions