我一直在尝试使用 ajax 提交文件$.post
。
var json_data = update_json_({name:first_name+' '+last_name,email:email,email2:email2,tele:tele,message:message,cc:$("#cc<?php echo $rand; ?>").val(),scauth:'<?php echo $auth_code; ?>'});
$.post
(
'<?php echo PATH_TO_PROCESSING_SCRIPT; ?>?r=<?php echo $rand; ?>&nocache=' + Math.floor(Math.random()*1000), json_data,
function(data)
{
// place the returned data in the results div
$("#results<?php echo $rand; ?>").html(data);
// div#response is returned by send.php. if the submission was successful, div#response will have the class ui-state-highlight. otherwise, the submission failed. Hide the form on success.
if($("#response").hasClass('ui-state-highlight'))
{
$('#c-form<?php echo $rand; ?>').hide('slow');
}
}
); //close $.post
这是将File
对象附加到javascript object
.
function update_json_(json_data)
{
if(has_element("input[type=file]"))
{
var inputs = $("input[type=file]");
fileobjs = [];
for (var i = 0; i < inputs.length; i++)
{
fileobjs.push(inputs.eq(i).prop("files")[0]);
}
$.extend(json_data, { files : fileobjs } );
}
return json_data;
}
但目前,我在萤火虫中遇到错误。
NS_ERROR_XPC_BAD_OP_ON_WN_PROTO: Illegal operation on WrappedNative prototype object
[Break On This Error]
...catch(c){return _.u}},stringify:function(f){function g(c){return h.call(this,c,a...