下面是我的代码,它在Chrome上工作正常,但Firefox在我的代码中save2.php
上显示403禁止的AJAX请求错误。另外为什么要花这么多时间加载?
场景:提交到preview.php
的表单,其中返回div作为响应。返回的div将转换为图像并发送到save2.php
,将图像保存到服务器。
$('.sharer').click(function(e){
$(this).html("<img src='img/spinner.gif' style='pointer-events: none; cursor: default;'/>");
e.preventDefault();
$.ajax({
type: "POST",
cache: false,
url: this.href, // our preview file (preview.php)
data: $("#myForm").serializeArray(), // all the fields in your form (use the form's ID)
success: function (response) {
$(".the-return").html(response);
elem = $('.the-return');
html2canvas(elem, {
onrendered: function(canvas) {
var img = canvas.toDataURL("image/png");
var output = encodeURIComponent(img);
var Parameters = "image=" + output;
var me = this;
}
}); //HTML2CANVAS
$.ajax({
type: "POST",
url: "save2.php", // Only Firefox showing 403 forbidden
data: Parameters,
success: function (datas) {
$(".sharer").html("<img src='img/share.png'/>");
//$(".imgs").html(datas);
FB.ui(
{
method: 'feed',
name: 'XXXX',
link: 'XXXX',
picture: 'XXXX/'+datas,
media: [{'type': 'image', width: '586', height: '586'}],
caption: 'XXXX',
//type: 'video',
description: 'XXXX',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
} else {
}
}
); //Fb Sgare
}
});
} // success
}); // ajax
}); // on click