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"