我正在尝试在插件初始化的“success”参数中进行简单的ajax调用。
我知道我正在寻找的数据实际上有一个值 - 当我输出data.videoID
时实际显示一个值,所以我开始认为它是ajax调用本身。我哪里出错了?该插件是Framebase.io的视频上传/管理工具。
framebase_init(
{
token: 'XXXXXXXXXXXXXXXXXXX',
events: {
upload: {
success: [
function(data){
alert("woo hoo! it's done!");
e.preventDefault();
dataString = data['videoID'];
$.ajax({
type: "POST",
url: "process_test.php",
data: dataString,
dataType: "json",
success: function(data) {
if(data.email_check == "invalid"){
$("#message_ajax").html("<div class='errorMessage'>Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.</div>");
} else {
$("#message_ajax").html("<div class='successMessage'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>");
}
}
});
}
]
}
}
});
此时,我已尝试将请求拆分为多个功能,但没有运气。
<script type="text/javascript">
var callback = function()
{
alert('success?');
}
var test = function(data, cb) {
$.ajax({
type: 'POST',
url: 'process_test.php',
data: data,
dataType: "json",
success: cb
});
}
framebase_init(
{
token: '**************',
events: {
upload: {
success: [
function(data){
alert("woo hoo! it's done!");
test(data['videoID'], callback);
}
]
}
}
});
</script>
或许我正在使用的插件干扰了请求?对于PHP文件,我尝试了echo
,print_r
,$_REQUEST
以及foreach
建议,但没有运气。有什么想法吗?