I am using ajaxFileUpload jQuery plugin to upload an image to ASP.NET server.
I was able to upload an image successfully, but I also want to pass data to the server as well. I wasn't able to do so. When I try to pass a JSON data I get the following error in the browser's console:
jQuery.handleError is not a function
The Javascript code:
$.ajaxFileUpload
(
{
url: 'http://localhost:23999/administration.asmx/UploadedFile',
secureuri: false,
fileElementId: 'ImageUpload',
dataType: 'json',
data: "test",
success: function (data, status) {
if (typeof (data.error) != 'undefined') {
if (data.error != '') {
alert(data.error);
} else {
alert(data.msg);
}
}
},
error: function (data, status, e) {
alert(e);
}
}
)
WebService C#:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string UploadedFile()
{
var a = HttpContext.Current.Request;
HttpPostedFile file = HttpContext.Current.Request.Files[0];
byte[] buffer;
Stream fileStream = file.InputStream;
............
How can I pass JSON data to the server? Thanks.