[Solved] How to use JQuery in MVC Asp.net


The main use of that code is to create an Ajax request that will not cause your page to load or refresh. Furthermore, it will be managed asynchronically.

In other words, you can send a request to the server and process the response without the need to reload.

url: VirualURL + "/Register/ValidatePromRep"

This URL will be routed to a controller, which is going to recieve the variable promRepNo as input and return a response in JSON format. If the response is successful, then this function is going to process it’s data:

function (data) {
    if (data.Message == "false")
        document.getElementById('divPromRepDoesNotExist').style.display = 'block';
    else
        document.getElementById('divPromRepDoesNotExist').style.display = 'none';
}

Remember that the controller can filter the request by it’s type (POST) with the [HttpPost]
tag and identify that it was an Ajax request with HttpContext.Request.IsAjaxRequest()

solved How to use JQuery in MVC Asp.net