(UPDATED) Jquery: trouble with file uploading throught .ajax -


sorry mispellings, english not main language.

i have jquery code in put data in plainobject type variable, use .post method send server.

conj = { form_type : 'event',           event_process_id : '1', //value defined when loading page           event_sequence : '10', //value defined when loading page           event_step : 'value', //value defined when loading page           event_type_id : $('#event_type_id').val(),           event_description : $('#event_description').val(),           event_date : $('#event_date').val(),           mode : 'save'         };    $.post('aux_process_form.asp',         conj ,         function (data) {            $.fulfill_event_information(); //this procedure update                                            //areas of page;                                           //don't worry            alert(data); //alerts user if there success or failure          });

this has worked me, need upload file information.

i've added page, had no success in uploading file successfully.

for instance, tried use $('#event_file').val() in plainobject, seems not work. can me solving or changing code address problem?


update 11/13/2016

after seeing other similar questions in these forums, found out how attach file, whenever attach file plainobject variable (conj in above example), %.post function won't work.

i tried change code. instead of plainobject store date, tried formdata object. , instead of $.post function, tried $.ajax function. new code this:

var myfile; //will store file name var attachment; //will store file  if ($('#event_file_selected').val() == "1" && $('#event_file').val() != "") {     myfile = $('#event_file').val();     attachment = $('#event_file')[0].files[0]; } else {     myfile = '';     attachment = ''; }  var conj = new formdata(); conj.append('form_type','event'); conj.append('event_process_id','1'); conj.append('event_sequence','10'); conj.append('event_step','value'); conj.append('event_type_id',$('#event_type_id').val()); conj.append('event_description',$('#event_description').val()); conj.append('event_date',$('#event_date').val()); conj.append('mode','save'); conj.append('event_file_selected',$('#event_file_selected').val()); conj.append('event_file',myfile); conj.append('event_attach',attachment);  $.ajax({     url: 'aux_process_form.asp',     type: 'post',     data: conj,     cache: false,     contenttype: false,     processdata: false,     success: function(data){         $.fulfill_event_information();         alert(data);     } }); 

as per other examples in these forums, new code should work. isn't. $.ajax function fire , complete, returning success, it not sending data server.

things have tried: - using plainobject send data throught .ajax function. same result: no data being sent. - using formdata variable .post function. didn't work, code stops working.

i have no idea why data not being sent. said above, when use .post method, works long there's no file attached. .ajax method not working how should.

does have advice?


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -