Jquery 将数据从视图传递到包含多个操作的api控制器

Jquery 将数据从视图传递到包含多个操作的api控制器,jquery,asp.net-mvc-4,Jquery,Asp.net Mvc 4,在api控制器中,我有不止一个方法如何将数据从视图传递到特定方法 public List<ListofUsersusingthisTechnology> getUsersUsinThisTechnology() { return dataHelper.GetListofUsingThisTechnology(); } public List<TechnologyDocumentation> PostTechnologyDocumentation(Technolo

在api控制器中,我有不止一个方法如何将数据从视图传递到特定方法

public List<ListofUsersusingthisTechnology> getUsersUsinThisTechnology()
{
    return dataHelper.GetListofUsingThisTechnology();
}

public List<TechnologyDocumentation> PostTechnologyDocumentation(TechnologyDocumentation TechDocumentation)
{
    List<TechnologyDocumentation> tech = new List<TechnologyDocumentation>();
    tech.Add(TechDocumentation);
    return tech;
}
public List getusersusinthisttechnology()
{
返回dataHelper.GetListofUsingThisTechnology();
}
技术文档后公开列表(技术文档技术文档)
{
列表技术=新列表();
tech.Add(技术文档);
返回技术;
}
这两个是我的api控制器中的操作。 我希望使用ajax调用将数据从视图发送到此api控制器中的特定操作,即posttechnologydocumentation

我尝试使用url调用该api,但它给了我一个错误,如
找到多个与请求匹配的操作:“

您可以使用jquery ajax调用进行相同的操作。假设您必须执行多个操作,并且只将数据传递给第一个操作。然后使用jQueryAjax调用,并在内部成功调用另一个操作

jQuery.ajax({
        type : 'POST',
        url : "http://localhost:8080/yourapp/controller/callingmethod",
        dataType : "json",
        data:jsonvar,
        contentType : "application/json;charset=utf-8",
        success: function() { alert('Success!' ); /* call another action here */},
        error: function() { alert('Hushhhhhhhhhhhh error!' ); }
    });

匹配多个操作的请求是什么?是否有多个操作与之匹配?(问题中的两个是不同的,因此显然有更像这两个的。)任何给定的URL都应该路由到一个动作。向该操作传递数据只需在GET或POST请求中包含值即可。您似乎缺少一些属性!?为什么不将[HttpGet]和[HttpPost]添加到您的操作中呢?是的,我正在进行类似于$.ajax的ajax调用({url:'',contentType:'application/json;charset=utf-8',type:'POST',data:json.stringify(TechDocumentation),complete:function(){alert(“succeed”)},success:function(result){$.each(result,function(index,value){};};应该使用
Url.Action
帮助程序来构造Url,以便使用路由信息。那么问题是什么?您不能将数据发送到特定的操作调用还是什么?是的,我无法将数据发送到api ControllerId中的特定操作。您的操作调用正在消耗您发送的数据。我的意思是当您如果将数据作为JSON发送,则您的操作方法调用必须作为JSON。@RequestMapping(value=“/methodcall”,method=RequestMethod.POST,headers={“application:JSON”})public@ResponseBody String yourmethod(@RequestBody HashMap reqDataMap,HttpServletRequest request){/*您的代码在这里*/}