Reputation:
I am getting user movie interst and posting it to another page using ajax requst as below. I want to send some other variables along with existing var a
.
FB.api('/me?fields=movies,email', function(mydata) {
console.log(mydata.email);
console.log(mydata.id);
var myid=mydata.id;
var name=mydata.name;
var email=mydata.email;
var imgpath="https://graph.facebook.com/"+myid+"/picture?type=small";
// I want to send myid,name,email with a in below code. How can I do and receive it on movies_db.php?
$.post('movies_db.php',{'myd':a},function(data){
$.ajax({
url:'url.php'
,async: true
,cache: false
,dataType: 'html'
,success: function(data){
$('body').html(data);
FB.XFBML.parse();
}
});
});
I want to send myid,name,email with a in below code. How can I do and receive it on movies_db.php?
Upvotes: 0
Views: 90
Reputation: 20820
Create object from the data and post it to server.
var myid=mydata.id;
var name=mydata.name;
var email=mydata.email;
var imgpath="https://graph.facebook.com/"+myid+"/picture?type=small";
var inputdata = {}
inputdata = {'myid': myid,
'name' : name,
'email' : email,
'imgpath' : imgpath
}
// Use inputdata as post data here
$.post('movies_db.php',inputdata,function(data){
$.ajax({
url:'url.php'
,async: true
,cache: false
,dataType: 'html'
,success: function(data){
$('body').html(data);
FB.XFBML.parse();
}
});
});
Now you can access POST data in your php file.
Upvotes: 0
Reputation: 638
What about this
FB.api('/me?fields=movies,email', function(mydata) {
console.log(mydata.email);
console.log(mydata.id);
var myid=mydata.id;
var name=mydata.name;
var email=mydata.email;
var imgpath="https://graph.facebook.com/"+myid+"/picture?type=small";
// I want to send myid,name,email with a in below code. How can I do and receive it on movies_db.php?
$.post('movies_db.php',{'myd':myid, 'name': name, 'email': email},function(data){
$.ajax({
url:'url.php'
,async: true
,cache: false
,dataType: 'html'
,success: function(data){
$('body').html(data);
FB.XFBML.parse();
}
});
});
}
Upvotes: 0
Reputation: 1516
You can pass as many key/value pairs as you want
$.post('movies_db.php',{'myd':a, name: name, email: email, parameter_name: value}, ...
In your PHP - movies_db.php
$email = $_POST['email'];
$name = $_POST['name'];
$other = $_POST['parameter_name'];
Upvotes: 1