MVC ajax post to controller action method

后端 未结 4 1705
慢半拍i
慢半拍i 2020-12-15 23:28

I\'ve been looking at the question here: MVC ajax json post to controller action method but unfortunately it doesn\'t seem to be helping me. Mine is pretty much the exact sa

4条回答
  •  孤街浪徒
    2020-12-16 00:01

    try this:

    /////// Controller post and get simple text value 
    [HttpPost]
        public string Contact(string message)
        { 
            return "

    Hi,

    we got your message,
    " + message + "
    Thanks a lot"; }

    //// in the view add reference to the Javascript (jQuery) files

    @section Scripts{
    
    
    
    
      
    }
    

    /// then add the Post method as following:

    
    
                                     
                  
提交回复
热议问题