Reputation: 309
I have a facebook app that works in all other browsers but IE. Here is my javascript code:
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
window.fbAsyncInit = function() {
FB.init({
appId : '123456789', // App ID
channelUrl : 'http://test/channel.php', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
oauth : true // turn on oauth
});
// Additional initialization code here
};
function start() {
//send initial AJAX request
var bike_var = $("select#bike").val();
var reason_var = $("textarea#reason").val();
var dataString = 'bike='+ bike_var + '&reason=' + reason_var;
$.ajax({
type: "POST",
url: "save.php",
data: dataString,
success: function(data) {
//set ID in the form
$("input#recordID").val(data);
doLogin();
}
});
}
function doLogin() {
//Do request to Facebook to get user details and then post to wall and the submit the form
FB.login(function(response) {
if (response.authResponse) {
getUserInfo();
} else {
alert("Sorry! We can't enter you into the competition unless you allow our Facebook app!");
}
}, {scope: 'email, publish_stream'});
}
function getUserInfo() {
FB.api('/me', function(info) {
$("input#name").val(info.name);
$("input#email").val(info.email);
$("input#FID").val(info.id);
var params = {};
params['message'] = $("textarea#reason").val();
params['name'] = 'Test';
params['description'] = '';
params['link'] = 'http://www.facebook.com/ChainReactionCycles';
params['picture'] = 'http://crc.test/img/logo.gif';
params['caption'] = 'Test';
postToWall(params);
});
}
function postToWall(param) {
FB.api('/me/feed', 'post', param, function(wall) {
if (!wall || wall.error) {
} else {
document.forms["comp-entry"].submit();
}
});
}
Here is code for my submit button that kicks off the code, currently working in all other browsers:
<input type="submit" name="submit_button" value="Enter Competition" onclick="start(); return false;">
In IE, this just goes to a blank page with the record ID of the new record, but in my database none of the required facebook fields are filled. The error in IE when i debug is 'SCRIPT5002: Function expected'. If anyone has any ideas i would be eternally grateful
Upvotes: 0
Views: 758
Reputation: 21
I had the same error message on my script and googled for that error code, so I accidently stumbled across your question. your line of code, that kicks the error helped me, so I can help you now.
Obviously IE 9 does not like "start" as a function name. I had the same function in my code, and after I found that redundancy between my own code and yours, I replaced the function name, et voila, everything works fine now.
Upvotes: 2