0

So this is my hook and function:

add_action('wp_ajax_AjaxAddDev', 'AjaxAddDev');

public function AjaxAddDev() {

    if (isset($_POST['name']) && isset($_POST['desc'])) {
        $name = $_POST['name'];
        $desc = $_POST['desc'];

        return "Name: ".$name." Description:".$desc;
    }

    return "Problem with data";
    die();
}

and this is the HTML form and Jquery call, the purpose is to basically add a name and description to a table in a database but I want to get it returning the submitting name and desc first.

            jQuery('#add_dev').bind('submit', function() {
                var url = "<?php echo(get_bloginfo('url')); ?>";
                var form = jQuery('#add_dev');
                var data = form.serialize();
                data.action = 'AjaxAddDev'
                jQuery.post(url+'/wp-admin/admin-ajax.php?', data, function(response) {
                    alert(response);           
                });
                return false; 
            });

    <form method="post" action="" id="add_dev">
        Development Name: <input type="text" name="name">
        Description: <input type="text" name="desc">
        <input type="submit" value="Add Development">
    </form>    

Anyone got any ideas?

The response is always "0"

Someone
  • 894
  • 3
  • 22
  • 43
  • Ok I am trying to work through that post just now I did see that earlier but I based my solution of what I considered to be a much simpler method of doing it. – Someone Nov 01 '13 at 13:08
  • OK I think im getting somewhere, my script isn't being included on the page I wanted it to be but I think I know why that is... and to think I used to like wordpress. – Someone Nov 01 '13 at 14:00
  • If you have some doubt on that code, ping me in the other thread. – brasofilo Nov 01 '13 at 14:16
  • I posted a comment on the other thread you answered, this not working is probably due to the usual problem of my own stupidity – Someone Nov 01 '13 at 14:28

0 Answers0