Shiva Bhusal
Shiva's Blog

Follow

Shiva's Blog

Follow

Submit files using jQuery Ajax

Shiva Bhusal's photo
Shiva Bhusal
·Sep 25, 2014·

1 min read

Play this article

Ajax

Ajax is a lot of web improvement procedures utilizing many web innovations on the customer side to make offbeat web applications. With Ajax, web applications can send and recover information from a server non-concurrently (out of sight) without meddling with the presentation and conduct of the current page. By decoupling the information trade layer from the introduction layer, Ajax permits website pages and, by augmentation, web applications, to change content powerfully without the need to reload the whole page by and by, current usage generally use JSON rather than XML.

Ajax is a set of web development techniques using many web technologies on the client side to create asynchronous web applications. With Ajax, web applications can send and retrieve data from a server asynchronously without interfering with the display and behavior of the existing page.

Simple example

$.ajax({
  url: "test.html",
  context: document.body
}).done(function() {
  $( this ).addClass( "done" );
});

How?

$('#myForm').submit(function(e){
     e.preventDefault();
    //Submit the form via ajax
    var formData = newFormData(this);

     $.ajax({
        url: $(this).attr("action"),
        type: "post",
        data: formData,
        cache: false,
        contentType: false,
        processData: false,
        success:function(response){
            //Success Job }
        });
})
 
Share this