c# - Switching from POST to GET for jqGrid populated from WCF back-end -


I'm trying to change my client side AJAX-calls and jqGrid to use GET instead of POST .

I have confirmed that working with the purpose of service is checked in firebug and inspected the JSON reaction object and that is correct - although I am still missing something on the client side because the data No specific javascript errors are seen in the firebug not coming in the grid.

I have a question about how to contact the .jax () request URL / data parameters when using GET instead of post. I do not really need to pass a parameter through the data parameter if I can exceed the parameters with the specific urlplate in the URL, then I think?

  function getData (pdata) {var jqGridArgs = {startdate: pdata.startDate (), expiration date: pdata.endDate ()}; Var _url = "Service. Svc / product? S =" + jqGridArgs.startDate + "& e =" + jqGridArgs.endDate; $ .ajaks ({type: "GET" content type "application / Jason; charset = UTF -8", url: _uarel, // data: Jesaankstringeijh ({Arges: Jekgreedaarjis}); // I need it Type 'data' for 'GET': "JSN", success: function (data, textstats) {if (textstat == "success") {var thegrid = $ ("# jqGrid") [0]; thegrid .addJSONData D);}}, Error: function (data, textstats) {warning ('an error data has been retrieved.');}}); }   

and grid code:

  var start = page.queryitem ('s'); Var end = page.queryitem ('E'); {Name: "id", index: "id", width: 175}, {name: "name", index: "name", width: 250}, {name: "type", index: "type", width : 250}]; Var columnname = ['product id', 'name', 'type']; $ ("#JqGrid") JqGrid ({postData: {startDate: function () {return start;}, expiry date: Work () finally {return;}} datatype: function (Peediattia) {GetData (Pdata); // above with Coldeta work column: column: Colmnam, Colmodel: Stnbmodl, line 10, line list: [10, 20, 30], audience: pagination wrong page: right, pager: "# Jekpigr" Lodons truth, sortorder : "Desc", sortname: 'id', cellEdit: false});   

And here is the previous WCF method:

  [WebGet (UriTemplate = "product? S = {start} & e = {end}" , ResponseFormat = WebMessageFormat.Json]] public JsonGridContract WebGetProducts (string Start, and string) {DateTime _start = Convert.ToDateTime (start.ReplaceIf ( 'T', '')); Date time _end = convert. ToDateTime (end. ReplaceIf ('T', '')); Var rows = GetProducts (_start, _end). Select (x = & gt; new {id = x.id, name = x.Name, type = x.Type}). Return to Toson (); New JasonGride Contract (Returns = Rows.Count, Total = Rows.Count, Page = 1, Rows The data is explained before going to the customer:   [DataContract] Public class JsonGridContract {[DataContract ] Public Square JsonRow {DataMember} Public Entry ID {Receive; Set;} [Database] Public String [] Cell {Received; Set;} Public JsonRow (int Length) {Cell = New String [Length];}} [Database ] Public Int page {get; Set; } [Datamember] Total full of public {received; Set; } [Detamember] public variation Get Record (; set;} [Detamember] public List & lt; JsonRow & gt; the rows {X; set;} public JsonGridContract () {rows = new List & lt; JsonRow & gt; ();} Public JsonGridContract (list & lt; JsonRow & gt; _rows) {rows = _rows;}}    

Try it:

  var jqGridArgs = {S: pdata.startDate (), e: pdata.endDate ()}; Var _url = "service. svc / product "; $ .ajax ({type:" GET ", url: _url, data: jqGridArgs, datatype:" Jason ", success: function (data ) {Var thegrid = $ ("# jqGrid") [0]; thegrid.addJSONData Data.d);}, error: function (data, textstats) {warning ('an error data has been retrieved.');} });   

There is no need to check success, if the success function is being called, then the operation was successful;

This also makes more because JQuery will automatically parse it and use it for query parameters to use your Javascript object to pass as data to get one. Apart from this, there is no need for content type after getting one, and no post.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -