wcf - How to Send a List in jQuery to WebApi -


i have webapi returns list , take list of key value pair

public list<mycustomers> getcustomerdetails(list<keyvaluepair<string, string>> searchcriteria)        {  } 

i using ajax call service :

jquery.support.cors = true;         $.ajax({             url: 'http://myserver/vccsearchrestservice/api/vccsearch/getcustomerdetails?   searchcriteria=whatshoudipasshere',                 datatype: 'jsonp',                 jsonpcallback: 'myjsonpcallback',                 type: 'get',                 // specify callback name if you're hard-coding                 success: function (data) {                     // make successful jsonp call!                 }             }); 

do post method

public list<mycustomers> postcustomerdetails(list<keyvaluepair<string, string>> searchcriteria) { { 

ajax call

 var keyvaluepair = [{"key1","value1"},{"key2","value2"}]; $.ajax({     url: 'http://myserver/vccsearchrestservice/api/vccsearch/postcustomerdetails',     datatype: 'json',     jsonpcallback: 'myjsonpcallback',     data: json.stringify(keyvaluepair);  // pass list here     type: 'post',     // specify callback name if you're hard-coding     success: function (data) {         // make successful jsonp call!     } }); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -