Thursday 15 January 2015

c# - can not invoke webmethod to save handsonTable -


I want to save the handphoneable data in the json file, to get all data as handy For a javas cript method is

  $ ('button [name = save]'). Click (function () {var str = handsontable.getData (); var value = JSON.stringify (str); $ .ajax ({url: "WebService.asmx / getData", data: {'data': value} , Datatype: 'Jason', Content Type: 'Application / Jason', Type: 'Post', Success: Function (Race) {if (Res Results == 'OK') {Warning ('Data saved');} And {warnings ('save error');}}, error: work (xhr, err) {warning ("ready location:" + xhr.readyState + "\ Nstatus:" + xhr.status);}}})}} };   

But I am not able to implement WebService.asmx / getData (list data).

  public A string getData (list & lt; string & gt; data) {return "";}   

Why do I need to pass in the data: ?? ... please help.

ContentType setting You are telling the server that you are sending JSON data , But you are not. {'data': str} is not a JSON string; This is a standard JavaScript object literally, you are implementing the default jQuery behavior to create HTTP requests This means that you are sending a regular HTTP request, something like this:
  data = thedata   

to send the actual JSON data, you Need to call :

  Data: JSON.stringify ({'data': str}), data type: 'json', contentType: 'Application / json',    

No comments:

Post a Comment