I\'m trying to call a function using ajax, but it\'s not responding.
Here is the Code:
Ensure That jQuery Is Working
Firstly, ensure that your jQuery code is working properly and is referenced. You'll need to include a reference to the library prior to calling any jQuery-related code :
If you want to perform a GET
...
You are specifying within your ajax() call that you are making a POST
request via the type
attribute, but your Controller Action is explicitly expecting a GET
via the [HttpGet]
attribute decorating your action.
You can resolve this by changing your type
attribute from POST
to GET
(or you could remove it entirely as GET
is the default):
type: "GET",
If you want to perform a POST
...
Alternatively, if you want to actually perform a POST
, then just keep your existing code and use the [HttpPost]
attribute instead :
[HttpPost]
public ActionResult Remove(int? Book_id)
{
// Code omitted for brevity
}