jQuery AJAX call returns "Not Found" error when attempting to upload image
Partha Mandayam
91
Reputation points
// Function to handle file upload
alert("handlefileupload");
$.ajax({
type: "POST",
url: "ImageUploader.ascx/HandleFileUpload",
data: '', //formData,
//contentType: false,
//processData: false,
success: function (data) {
// Handle the server response here
alert("success");
document.getElementById('<%= Label1.ClientID %>').innerText = "File uploaded successfully.";
},
error: function (xhr, status, error) {
// Handle error if necessary
alert("error");
console.log(error);
console.log(status);
console.log(xhr);
}
});
I have a function to handle a file upload but it is returning a "Not Found" error. The code should look for "HandleFileUpload" inside control "ImageUploader.ascx" code behind, but it's behaving strangely and creating a URL as "http://localhost:56722/ImageUploader.ascx/HandleFileUpload". Why is this happening?
Developer technologies | ASP.NET | Other
3,598 questions
Sign in to answer