hello! I'm adding AJAX functionality to a plugin wordpress
the script to work load I a number inside a div, I would simply load it when i click a button, passing parameters, It's jQuery could you help me?
I replaced this
jQuery (document). ready (function ($) (
with
jQuery (". inputsubmit). click (function () (
with this button:
$ Out .= "<button type='button' class='next right' class='inputsubmit' id='".$orderitem-> idorder." '> Details </ button> ";
Then there echo
but it doesn't work, perhaps because the buttons are so many and dynamically generated for each record in the db What can I do to activate the button's onclick?
this is the code:
thank you if you help meCode:function my_action_javascript() { ?> <script type="text/javascript" > //$('#myButton').click(function(){ jQuery(document).ready(function($) { var data = { action: 'my_special_action', whatever: 7777 }; // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php jQuery.post(ajaxurl, data, function(response) { //alert('Got this from the server: ' + response); document.getElementById("results_id").innerHTML =response; }); }); }); </script> <?php } function my_action_callback() { global $wpdb; // this is how you get access to the database $whatever = $_POST['whatever']; $whatever += 10; //echo "document.getElementById('results_id').innerHTML ='$whatever';"; echo $whatever; die(); }


LinkBack URL
About LinkBacks
Reply With Quote