How to make simple AJAX call on HTML input button and get JSon result in MVC 3

Here is the simplest code to make Ajax calls to MCV on an HTML button click using javascript.


JS Code:
funtion btnClick(){
var URL = "/myController/ myAction ?userID=" + Parameter1 + "&ReceiptNo=" + Parameter2 ;
                    $.get(URL, function (data) {
                        ShowResult(data.ProcessResult);
                         }

HTML Code (View):

  <input name="ClickedButton" type="button" id="btnclickme" value="Check Result"
                    onclick="btnClick()" class="commonbtn FR" />

C# Code (Controller):
public ActionResult myAction(string Parameter1,string Parameter2 )
{
    int ProcessResult = 1;

    return Json(new { ProcessResult }, JsonRequestBehavior.AllowGet);

}

Comments

Popular Posts

GREYCstoration Oil Paint plugin for Photoshop

Service Bus Gateway service stuck at Starting

PowerApps SubmitForm not clearing People Picker value

Apple iPhone sending SMS automatically 00447786205094

Download file failed signature verification and may have been tampered with - Workflow Manger 1.0 Refresh (CU2)