My ajax/jquery script to send $_GET to php isn't working? (Wordpress) -
this code i'm using send variable (via get) php file: (basically, click on button, , js gets id , sends id via ajax php file.
$(document).ready(function() { $(".doclick").click(function() { var category=$(this).attr('id'); $.ajax({ url:'afile.php', type:'get', data: $category, success: function(data){ alert("it worked?"); // response } }); alert($(this).attr("id")); }); }); this code in afile.php: php file gets info via $_get[] , assigns variable , uses variable in function call.
<head> <script type="text/javascript"> $(document).ready(function() { function js() { //code }); </script> </head> <body onload="js()"> <?php $category = $_get['category']; if (function_exists('inventory_insert')) { echo inventory_insert('{category_name = '.$category.'}'); } else echo('warning'); ?> it's supposed give me response on main page, nothing seems happening. don't alert posted after ajax script.
your variable category you're sending data: $category
Comments
Post a Comment