我需要调用一个web api,这个web api方法接受两个参数,一个是枚举类型,另一个是int.我需要使用Ajax Jquery来调用这个api.如何通过枚举参数.
API代码
[HttpGet]
public HttpResponseMessage GetActivitiesByType(UnifiedActivityType type, int pageNumber)
{
var activities = _activityService.GetAllByType(type, pageNumber);
return Request.CreateResponse(HttpStatusCode.OK, activities);
}
Run Code Online (Sandbox Code Playgroud)
我的Ajax电话代码:
var jsonData = { 'type': 'Recommendation', pageNumber: 0 };
$.ajax({
type: 'get',
dataType: 'json',
crossDomain: true,
url: CharismaSystem.globaldata.RemoteURL_ActivityGetAllByType,
contentType: "application/json; charset=utf-8",
data: jsonData,
headers: { "authorization": token },
error: function (xhr) {
alert(xhr.responseText);
},
success: function (data) {
alert('scuess');
}
});
Run Code Online (Sandbox Code Playgroud)
有什么建议..