Reputation: 3807
i am using following code to publish Image on facebook
$.ajax({type: "POST",
url: "https://graph.facebook.com/me/photos",
data: {message: "",
url: "my Image url",
access_token: accessToken,
format: "json"},
dataType: "json",
success: function(data){
uploads(id);
},
error: function(data){alert("Failed! " + data.error);}
});
This code works fine on Chrome, firefox and any other browser invented in the world but it is not working in Internet explorer. Whats wrong in this code??
Upvotes: 1
Views: 2817
Reputation: 96306
Whats wrong in this code?
Wrong question :-)
Right question: Why are you trying to do this yourself via AJAX – instead of just using the JS SDK and call it’s API method?
That will take care of everything for you.
Upvotes: 0
Reputation: 87073
This is a cross-domain request. So use
dataType: "jsonp",
set jsonpCallback
to ajax config. That is:
$.ajax({
type: "POST",
url: "https://graph.facebook.com/me/photos",
data: {
message: "",
url: "my Image url",
access_token: accessToken,
format: "json"
},
dataType: "jsonp",
jsonpCallback: 'blah', // here
success: function(data) {
uploads(id);
},
error: function(data) {
alert("Failed! " + data.error);
}
});
Upvotes: 3