我在做什么是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添加到页面中? –