我有一個Facebook應用程序,在所有其他瀏覽器,但IE瀏覽器。這裏是我的javascript代碼:與IE9的AJAX問題
(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();
}
});
}
這裏是我的提交按鈕,揭開序幕的代碼,目前在所有其他瀏覽器中工作代碼:
<input type="submit" name="submit_button" value="Enter Competition" onclick="start(); return false;">
在IE中,這只是去到一個空白頁與新記錄的記錄ID,但在我的數據庫中沒有填寫所需的Facebook字段。當我調試時IE中的錯誤是'SCRIPT5002:Function expected'。如果任何人有任何想法,我會永遠感謝
是否在調用save.php之前或之後發生空白屏幕? – DMCS 2012-02-29 22:24:56
它發生在 – user1240615 2012-03-01 09:13:11