Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Ajax call in wp-oauth plugin

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 108
    Comment on it

    Hello readers, today we discuss about "How to call Ajax in wp-oauth Plugin".

    "wp_ajax_your_function_name" its a pre define method for loged in users.

    You can put the below code into plugin.php file. "getMinorCatList" is a function where ajax can hit.

    <?php
        add_action( 'wp_ajax_getMinorCatList', 'getMinorCatList' );
    
        function getMinorCatList() {
        global $wpdb; // fetch data from database
        $minorCatList =  $_POST['minorCatList'];
        echo $minorCatList;
        wp_die(); // immediate return and die.
       }
    ?>
    

    You can put the below code into your page. In the below code 'action': 'getMinorCatList', hit the plufin.php file function and recieve the response.

     <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
    
        <script type="text/javascript">
            function setMajor(id) {
                var data = {
                    'action': 'getMinorCatList',
                    'minorCatList': 'Hello, I am here!!!'
                };
    
                jQuery.post(ajaxurl, data, function(response) {
                    alert('Got this from the server: ' + response);
                });
            }
        </script>
    

    Hope it helps you, thankyou.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: