hi.i have two problems with jquery $.ajax. first problem is ihave a php file named action.php and here the code:
if($_GET['action']=='add'){
//rest of the code here
}
And i use jquery $.Ajax function to call that when form fills:
$.ajax({type:"POST", url:"action.php?action=add", data:$("#form").serialize(), cache:false, timeout:10000});
this works but i wanted to know is there anyway to send the action=add code with data and not the url?
and the second problem that i have is that i have a link:
<a href="#" onclick="delete(4);">delete row from mysql where id is 4</a>
and a jquery function:
function deleteUser(id){
$.ajax({type:"POST", url:"action.php?action=delete", data:"id="+id, cache:false, timeout:10000});}
and of course the action.php code:
if($_GET['action']=='deletestudent'){
mysql_query("DELETE FROM `students` WHERE `student_id` = {$_POST['id']}");
}
but it doesn't work.what should i do?