我在做什麼是Facebook請求對話框,並從JavaScript獲取用戶ID,然後發佈到php代碼插入用戶ID在我的數據庫中,在我的Facebook請求對話框部分我可以獲取用戶ID和請求ID,只有ajax郵件部分不管用。爲什麼我的帖子ajax不工作?
我的JavaScript編碼:
function newInvite(){
FB.ui({
method : 'apprequests',
title: 'X-MATCH',
message: 'Come join US now, having fun here',
},
function(response){
var receiverIDs;
if (response.request) {
var receiverIDs = response.to; // GET USER ID
alert(receiverIDs);
//I stuck from here
$.ajax({
type: "POST",
url:"<?=$fbconfig['baseUrl']?>/ajax2.php",
data : {receiverIDs :receiverIDs},
success: function(msg){
alert(msg);
},
error: function(msg){
alert(msg);
}
});
}
}
);
}
我的PHP代碼(文件名是ajax2.php):
<?php
include 'config/config.php';
include_once "index.php";
$Currentdatetime = date("Y-m-d h:i:s" ,strtotime("now"));
$senderID = $_POST['receiverIDs'];
$explode = explode(',', $senderID);
for ($i=0; $i<count($explode);$i++){
mysql_query("INSERT INTO user_invite VALUES('$userid','$explode[$i]','0','50','$Currentdatetime','0')");
}
?>
任何解決方案?感謝
你是否試圖在螢火蟲控制檯中看到這個? – Arfeen
在我的firebug中顯示「$未定義」 – Oscar
@user您是否將jQuery添加到頁面中? –