开发者

Get Query String value with Jquery, AJAX in ASP.NET MVC

开发者 https://www.devze.com 2023-02-12 11:04 出处:网络
HI, i need to pass id=2 while calling the action method ? How can i pass id value to controller http://localhost:52391/Campaign/Edit/2

HI,

i need to pass id=2 while calling the action method ? How can i pass id value to controller

http://localhost:52391/Campaign/Edit/2

{Controller}=Product {ActionMethod}=Action {id} =2

开发者_如何学JAVA
 function getProductDetails() {           
           var link = '**/Product/Details?callback=?**';                      
            $.ajax({
                url: link,
                data: {},
                dataType: "jsonp",
                jsonpCallback: "doextrawork"
            });


var link = '/Product/Details?callback=?';
$.ajax({
    url: link,
    data: { id: '<%= ViewContext.RouteData.Values["id"] %>' },
    dataType: "jsonp",
    jsonpCallback: "doextrawork"
 });


simply pass a json object with your id as a property.

$.ajax({
    url: link,
    data: {
        id: 2
    },
    dataType: "jsonp",
    jsonpCallback: "doextrawork"
});
0

精彩评论

暂无评论...
验证码 换一张
取 消