Reputation: 191
Sorry it was a mistake to post a question about making a condition to checkbox earlier without further investigation. It seems i need to pass my variables here
function setsession(sessionid,action, data){
$("#totalselection").show();
$.ajax({
type:'POST',
url:'test.php',
data:'sBorrow='+sessionid+'&action='+action,
cache:false,
success:function(data){
var out = "<p align='center' style='text-decoration:none;color:white;'>Total Selection: "+data+"<br/>Click here to submit your request <a href='borrowform.php?subid=borrow' id='submitborrow' name='submitborrow' style='text-align:center;'><input type='button' value='REQUEST' id='submitborrow' name='submitborrow'></a> || Click here to clear the selection <a href='#' style='text-align:center;'><input type='button' value='CLEAR'></a></p>";
datachecked(data, this.indexValue);
$("#totalselection").html(out)
}
});
}
to the DOM of other php page. NOT TO THIS URL. It was different page. Im still not clear to this ajax and i know that ajax can only send to 1 url only. However i want the data value that this ajax hold to put it inside my php echo and make if else statement using that data. Should i create one more ajax? or else? How to send data from success to my php page and received it?
Upvotes: 0
Views: 250
Reputation: 319
$("document").ready(function () {
data = {
'name':'ys',
'surname':'ysss',
'pass':'123456',
'number':5
};
$.post('content.php',data,function(response,status){
if(status == 'success'){
$("#information").html(response);
}
});
you can send data as long as possible by writing to the 'data'
Upvotes: 0
Reputation: 26258
I think you are asking how to send your variable in ajax call. Try this simple syntax of jquery ajax call by which you can send any number of variables.
$.ajax({
url : 'process.php',
method: 'post',
data : {
var1 : val1,
var2 : val2
// by this way you can send multiple variable
},
success : function(response){
alert(response)
}
});
process.php:
$val1 = $_REQUEST['var1'];
$val2 = $_REQUEST['var2'];
// use it in your own way
Upvotes: 1