I have a trouble receiving data sent using ajax in a php file. It seems that ajax sends data, cause I get a success message, but php page shows me an error "Notice: Undefined index: ab".
Here is my jquery code for sending data using AJAX:
$('#download-btn').click(function(){
var ab="abc";
$.ajax({
url:'generate_url.php',
data:{'ab':ab},
type:'post',
success:function(data) {alert("sent");},
error: function(request, status, error) {alert(request,status);}
});
}
And that's how I extract data in a generate_url.php:
<?php
$a = $_POST['ab'];
echo $a;
?>
Thanks in advance for your help!
var_dump($_POST);show?data.)at the end of the function.success:function(data) { alert("sent...next see the data..."); alert(data); },is one way, but you need to find your javascript console. what browser are you using?