0

我想發送ajax窗體中的文本框的值開始並顯示相應的局部視圖但問題是它總是去post方法,但我的httpmethod方法也在Ajax表單Ajax窗體開始不會http GET方法

我的代碼是

@using (Ajax.BeginForm("UserMenuPermission", new AjaxOptions { HttpMethod = "Get", InsertionMode = InsertionMode.Replace, UpdateTargetId = "GridData" })) 
    { 
     <div> 
        @Html.Label("User Name") 
        <input type="text" placeholder="User Name" style="color: black;height:30px;" name="Username"/>        
        <input type="submit" value="Search" /> 
     </div> 
    } 

這個代碼可以將信息傳遞給UserMenuPermissionController POST方法,但我需要在GET方法傳遞,請幫助我的朋友

在此先感謝。

+1

。 – CSharper 2014-10-31 13:57:23

+0

這就是我有局部視圖和這種形式提交按鈕它必須去http獲取方法控制器 – Dinesh 2014-10-31 14:11:34

+0

但我想它得到的方法,我該怎麼辦 – Dinesh 2014-10-31 14:31:08

回答

2

我建議使用只要您提交這總是一個帖子jquery.ajax get方法

//Change your search button like this 
<input type="button" value="Search" onclick="ajaxCall()" /> 
//in javascript 
function ajaxCall() 
{ 
$.ajax({ 
    url: "ActionURL", 
    type:"get", //send it through get method 
    data:{} 
    success: function(response) { 
    //response is your partialview html 
    }, 
    error: function(xhr) { 
    //Do Something to handle error 
    } 
}); 

} 

在控制器

public ActionResult GetHtml() 
{ 
    return PartialView("UserDetails"); 
} 
+0

雅我的get方法是返回部分視圖我將如何做,可以請給我看任何示例 – Dinesh 2014-11-01 03:11:12

+1

@Dinesh我更新myAnswer – 2014-11-01 10:05:02