javascript - Missing parameter in Ajax post to Asmx -
i'm trying send string file asmx service , keep getting following error:
message: invalid web service call, missing value parameter: file stacktrace @ system.web.script.services.webservicemethoddata.callmethod(object target, idictionary`2 parameters) @ system.web.script.services.webservicemethoddata.callmethodfromrawparams(object target, idictionary`2 parameters)\\r\\n @ system.web.script.services.resthandler.invokemethod(httpcontext context, webservicemethoddata methoddata, idictionary`2 rawparams)\\r\\n @ system.web.script.services.resthandler.executewebservicecall(httpcontext context, webservicemethoddata methoddata)\",\"exceptiontype\":\"system.invalidoperationexception\"} here's js
function ajaxactionpostdata(service, operation, file, callback, async) { if (!async) { async = false; } $.ajax({ type: 'post', url: '/api/service.asmx/operation', contenttype: 'application/json; charset=utf-8', async: async, data: "{ 'file': '" + file + "' }", datatype: 'json', success: function (msg) { if (msg) { callback(msg.d); } }, error: errorhandler }); } when passed function above file has value of "test\r\n" escape characters messing it?
service code
[webmethod(enablesession = true)] [scriptmethod(responseformat = responseformat.json)] public bool uploadcsv(string id, string file) { string testfile = file; return true; } no other errors thrown, file not having value. i've tried various things cannot understand i'm missing?
try sending data plain object:
data: { 'file': file }, or string:
data: 'file=' + file, at moment you're doing little of both won't work.
Comments
Post a Comment