Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How do I set the beforesend option in WordPress AJAX? I want to show loading option.

This is my code:

function showmyvideos() { 
    var datas="data";
    var data = {
        action: 'my_vids',
        link: datas  
    }; 
    ajaxurl= "http://localhost/wordpress/wp-admin/admin-ajax.php";
    jQuery.post(ajaxurl, data,function(response) {

    });

}
share|improve this question
1  
This is the wrong way to do ajax within WordPress. The proper way is documented here: 5 Tips for Using Ajax in WP –  cale_b Mar 22 '12 at 23:46

1 Answer 1

You have two options:

  1. Use jQuery.ajax() instead of jQuery.post()
  2. Use jQuery.ajaxSetup() to change the beforeSend behavior globally.

Reference: http://stackoverflow.com/questions/2257975/using-beforesend-and-complete-with-post

share|improve this answer
    
thank you very much.can u edit my code. –  SANS780730 Mar 23 '12 at 0:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.