c# - WebMethod fails to capture object sent via ajax -


I am trying to get an object from the client in JavaScript so that it can be handled and processed by C # WebMath To send in So far, I have been unable to handle webmath coming to JSN object successfully.

My Javascript:

  var _Messages; Function callData () {var timeNow = new date; $ AJAX ({type: "POST", url: "default.aspx / all", data: '{}', content type: "app / jason; charset = utf-8", datatype: "jason", success: function (Data) {_Messages = data.d; render (data D); $ ('# updated_time') .HTML ("& lt; p class = 'text' & gt; last update:" + ("0" + TIME (2) + ":" + ": (" 0 "+ TIME. Gate Minutes ()). Piece (-2) +": "+" ("0" + TIME. GATE seconds ()). Piece (-2) + "& lt; / p & gt;")}, Failure: Function (Response) {alert.d);}});} Function print function () {var listofmsg = $ .grep (_Messages, function (A) {return.Text.t Rim (). Replace (/ \ r \ n | \ r | \ n / g, '') == $ ('#NavigateTrTD'). Eq (active * 2-1) .text () .tim ( Replace (/ \ r \ n | \ r | \ n / g, '');}); Listofmsg [0]. Text = listofmsg [0] .ext.replace (/ \ r \ n | \ r | \ N / g, ''); var msg = listofmsg [0]; // var input = {timestamp: msg.Text, timeout: msg.TimeSet, text: msg.Text, type: msg.Type, isgreen: msg .IsGreen} console.log (JSON.stringify ({'message': msg}); $ .aax ({type: "post", url: "default.aspx / printmessage", content type: "app / jason; Charset = UTF-8 ", Data Type:" Jason ", Data: JSON.stringify ({'Message': Msg}), Success: Function (Data) {console.log (data.d);}, Failure: Function {Response} {alert.d);}})}}  

My object:

  public class messages {public string timestamp {get; Set;} public date timetable {get; set;} public string text {get} set;} public string type {get; set;} public bubble easter {get; set;} Public Message (String Timestamp, Datetime Timetable, String Text, String Type, Bull Assignment) {Timestamp = Timestamp; Timetate = Titleset; text = text; type = type; IsGreen = isgreen;}}  
< P> My WebPage:

  [WebMethod] Public static bool print message (message message) {try {... return true} hold (exception ex) {... return false}} < / Code> 

My error is that when I arrive at WebMethod, message object is selected Yes, despite the fact that it is filled on the same customer side:

  {"message": [{"timestamp": "08:39:28", "timetet": "/ date ( "Test Test Test Test Test Test Test Test", "Type": "SPC", "EzGreen": True}]} > 

Any idea what is going wrong? My best estimate is that I'm not formatting the JasonOn object correctly,

( ) And it seems like "message" is an array / archive and therefore deserialisation will turn off a tad. You should either change your method in such a way:

Public Stable Bull Printmessage (List Message)

Or Array Delete the declaration ([] bracket) in your JSON object declaration and the same signature, which is

public static bull printmesses (message message)

< P> Modify for JSON object with:

{"message": {"timestamp": "08:39:28", "timeout": "/ date (1398727057151) /" , "Text": "tester" "Test Test Test", "Type": "SPC", "Ice Greens": True}} I'm thinking that the property "message" is also really important.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -