jQuery AJAX file upload returning errors, why? -
when upload file server, response either number or boolean, i'm getting error:
object {readystate: 4, responsetext: "", status: 200, statustext: "ok"} abort : (a) : () catch : (a) done : () fail : () getallresponseheaders : () getresponseheader : (a) overridemimetype : (a) pipe : () progress : () promise : (a) readystate : 4 responsetext : "" setrequestheader : (a,b) state : () status : 200 statuscode : (a) statustext : "ok" : (b,d,e) proto : object
my code this:
var btn = $("input[name=submitname]"); var url = btn.parents("form").attr("action"); var filename = btn.parents("form").find("input[type=file]").attr("name"); var fileval = btn.parents("form").find("input[type=file]").val(); var datastring = btn.parents("form").serialize() + "&" + btn.attr("name") + "=" + btn.val() + "&" + filename + "=" + fileval; $.ajax({ url: url, type: "post", data: datastring, processdata: false, contenttype: false, cache: false, success: function(data){ console.log(data); }, error: function(errdata){ console.log(url); console.log(datastring); console.log("error:"); console.log(errdata); } });
when use same code (without processdata, contenttype , cache) other forms don't have files works, files (images) above error. doing wrong?
Comments
Post a Comment