Using Ajax to send ID
-
I need help with this Ajax. I am trying to gather the ID from a select drop down and post it to use on another select.
My major issue was sending the ID. Becuase I was using WordPress it didn’t know how to send it. Now i know how to do that part. I made a test function to get the Ajax URL working. All it does now is show an alert “Hello World”. I want to remove the line to “Hello World” and replace it with posting ID.
ajaxurl = '<?php echo admin_url( 'admin-ajax.php'); ?>';<script type="text/javascript"> jQuery(document).ready(function() { var id = $("select#category option:selected").attr('value'); $("select#category").change(function(){ jQuery.ajax({ type: 'POST', url: ajaxurl, data: {"action": "hello"},//Just shows the result of hello function success: function(data){alert(data);}//Need to remove //jQuery.post( ajaxurl , { action:"my_action_name",id:"True" } ,function(data){ //This is what I found I need to work into my script. But not sure of the format. }); return false; }); }); </script>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Using Ajax to send ID’ is closed to new replies.