I have a form with a File Input and one Button, when I press the button the file should go to the server side.
When I send a file to the server the ajax response is success, never stop in the c# webmethod breakpoint that I use. What I am doing wrong?
The Form: (Default.aspx)
The Script: (Default.aspx)
function sendFile() {
var data = new FormData();
var file = $("#FileInput")[0].files[0];
data.append("name", file.name);
data.append("size", file.size);
data.append("type", file.type);
data.append("file", file);
$.ajax({
type: "POST",
async: true,
url: "Default.aspx/UploadBlock",
data: data,
cache: false,
contentType: false,
processData: false,
success: function (result) {
alert("Success: " + result);
},
error: function (xhr, status) {
alert("An error occurred: " + status);
}
});
};
The WebMethod: (Default.aspx.cs)
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static Respuesta UploadBlock()
{
Respuesta res = new Respuesta { Success = true, Message = "OK" }; //Break point here
return res;
}
Thanks.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)