How to upload file using jquery ajax() method?

Here i tried using below codes but it didn’t save file name in database but other text fields are saved.so my doubt is how to store file using jquery ajax() method.

$(document).ready(function(){
$("#category").click(function(){
var filename = $("#file").val();
$.ajax({
type: "POST",
url: "save.php",
data:$("#form-cover").serializeArray(),
success: function() {
alert("Inserted");
}
});
return false;
});
});

You should probably use a FormData object to accomplish this; Mozilla have a demonstration page here

The easiest and most cross-browser friendly method is to use an iframe as proxy.

Searching the query below in Google should yield some examples of implementations.

“using iframe to upload file with ajax”