3月 08, 2014

MVC

View:
<script>
    $(document).ready(function () {
        
        $("#s1").click(function () {
            var selected = $("#do1 option:selected");
            $.post("@Url.Content("~/store/bgg")",
                    {user:selected.val()},
                    function (res) {
                        alert(res);
                    });
            
        });
        //$("#do1").click
    })
</script>
<h2>indexstore</h2>
<select id="do1">
    <option>dog</option>
    <option>pig</option>
</select>
<input id="s1" type="submit" value="submit" />
controll加入:
public ActionResult bgg(string user)
{
            
    return  Content(string.Format("已傳送訊息給{0}",user));
}

沒有留言: