AJAX call then page redirect -


i can call ajax request when form submit button clicked, if page reloads/redirects due form submission, ajax request still complete? i'm asking upload file via ajax form submitted.

i'm pretty sure can't output of ajax call, wrong?

it's possible, there's no guarantee request have completed time leave page. if you're submitting form via ajax , want submit file, might consider placing file upload in separate form tag, trigger form submission after ajax call successful. example:

<!-- first form data --> <form action="/your/url/here" method="post" id="form1">    <input type="text" name="title" />    <input type="submit" value="save" /> </form> <!-- second form file --> <form action="/uploadfile" method="post" id="form2" enctype="multipart/form-data">    <input type="file" name="fileupload" /> </form> 

then in javascript (using jquery example brevity, note haven't tested code @ all):

$('#form1').bind('submit', function() {   $.ajax({       url: $(this).attr('action'),       data: $(this).serialize(),       type: 'post',       success: function() {         $('#form2').submit();       }   });   return false; }); 

Comments

Popular posts from this blog

jQuery clickable div with working mailto link inside -

java - Getting corefrences with Standard corenlp package -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -