In my website I have a link where user id is store like this :
<p>by <a href="#" onclick="ofUser(<?php echo $uid; ?>, event);"><?php echo $store_name; ?> (<?php echo $no_pro_of_user; ?>)</a></p>
Here you can see variable $uid
. This is the user id. So I want to make ajax call when I click on this link. It's should get the value of $uid
to result page ofUser.php
. But in result page (ofUser.php) it's showing :
Undefined index: id
Can you tell me how can I solve it ?
Here is the JS offUser function
function ofUser(id, event){
id = $(id);
event.preventDefault();
var formData = id;
$.ajax({
url : <?php echo "'ofUser.php'"; ?>,
type : 'POST',
xhr : function () {
var myXhr = $.ajaxSettings.xhr();
return myXhr;
},
beforeSend : function () {
$("#ofUser_message").val("Searching...");
},
success : function (data) {
$("#danger").hide();
$("#bydault_pagination").hide();
$("#bydeafult_search").hide();
$("#ofUser_message").html(data);
},
data: formData,
cache: false,
contentType: false,
processData: false
});
}
offUser.php
echo $uid = (int) $_POST['id'];