Quote:
var data = { Title: title, Description: desc, Category: cat Priority: prior, Attachment: attach };
That object literal is not valid. You're missing a comma between the category and priority properties:
var data = { Title: title, Description: desc, Category: cat, Priority: prior, Attachment: attach };
Quote:
data: '{' + JSON.stringify(data) + '}',
What you're sending at the moment is not valid JSON:
{ { Title: "...", Description: "...", Category: "...", Priority: "...", Attachment: "..." } }
Remove the extra braces from your posted data:
data: JSON.stringify(data),
{ Title: "...", Description: "...", Category: "...", Priority: "...", Attachment: "..." }
Quote:
var attach = $('#FileUpload1').val();
public static void insertion(..., string Attachment)
That's not how file uploads work. You're storing the path - or possibly just the name - of the file as it exists
on the user's computer. The path will not be valid on the server, or on any other computer that accesses your site.
It might
appear to work when you test the site in Visual Studio. But that's only because, in that specific case, the client and server are the same computer. As soon as you deploy your code to a real server, it will stop working.
To upload a file using AJAX, you will need to use the
FormData
object:
Using FormData Objects - Web APIs | MDN[
^]
On the server, you will need to use the
Request.Files
collection to access the uploaded file. You will need to save it somewhere on your server, and store the path where you saved it in your database.