我有我的WebApi,它返回一个列表,也获取一个键值对的列表
public List<myCustomers> GetCustomerDetails(List<KeyValuePair<string, string>> searchCriteria)
{
}我使用ajax来调用该服务,如下所示:
jQuery.support.cors = true;
$.ajax({
url: 'http://MYSERVER/VCCSearchRestService/api/VCCSearch/GetCustomerDetails?
searchCriteria=WhatShoudIPassHere',
dataType: 'jsonp',
jsonpCallback: 'MyJSONPCallback',
type: 'GET',
// specify the callback name if you're hard-coding it
success: function (data) {
// we make a successful JSONP call!
}
});发布于 2015-04-01 19:16:03
使用Post方法执行此操作
public List<myCustomers> PostCustomerDetails(List<KeyValuePair<string, string>> searchCriteria)
{
{Ajax调用
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 the callback name if you're hard-coding it
success: function (data) {
// we make a successful JSONP call!
}
});https://stackoverflow.com/questions/29388429
复制相似问题