Support » Plugin: AJAX Manufactory » Good plugin, saves time and pretty easy to use.

  • I found this plugin when I was trying to develop ajax content update with built in wordpress tools.
    Mostly syntax is pretty straightforward and self explanatory.
    Tricky part is when you need to pass variables back to page.
    Luckily plugin developer appeared very nice person and pointed me how to use plugin nice and easy.
    Now here’s the trick:
    Say, we want send two variables to php side, process that data and show alert only for birds.
    Note: you can change “myaction” to whatever you like.
    On html side we embed javaScript:

    jxAction('myaction', {'variable_name': 'apples','another_variable': 'penguins'}, function(v){
         alert(v['birds']);
    });

    On php side in functions.php we add action hook:

    add_action('jx_myaction', function($jx){
        $data = $jx->data; //this is array with our variables
        $bird = 'penguins';
        foreach ( $data as current_var ) {
            // here we write desired values to array that will be returned.
            if ( $current_var == $bird ) $jx->variable('birds', $fname);
        }
    });

    That’s pretty much it.

    p.s. IMPORTANT! In case of error on php side, you might get “Wrong jx JSON response (not JSON)” message. Then you should check webserver logs for errors.

    My recommendations, five stars.

  • The topic ‘Good plugin, saves time and pretty easy to use.’ is closed to new replies.