Not able to call controller method using Ajax call


    public void DeleteState(string id)
        int id1=Convert.ToInt32(id);
        var _db = new clubDataContext();
        var state = from m in _db.StateInfos where m.S_ID == id1 select m;
        foreach (var m in state)
        catch (Exception e)



<input id="state-id" type="text" value=@item.S_ID  style="display:none"/>
<a id="delete-link" href="" >Delete</a>

    url: '@Url.Action("DeleteState", "ManageSystem")',
    data: {'id':$("#state-id").val(); } ,
        success: function(result) {
        $('#edit-state').html("State Deleted Successfully");


I don't know what is the reason but controller method is not called when i click on Delete. Is there Ajax problem? I have included Ajax Library.

Main thing I forgot to mention that My view is partial view and I am calling controller method from this partial view. So I think jQuery is not loaded


I think the problem is : Your controller is of type HttpPost. make sure Ajax call is of type Post. Use type: "POST" for more info visit jQuery ajax Documentation.

Finally got the solution. This question is already asked before. Sorry for that!

Is it OK to put JavaScript in Partial Views

Here I got similar type of question in stackoverflow itself.

1)MVC4 partial view javascript bundling Issue



4)How to execute JavaScript function on PartialView load in MVC 3

So in my project, i made separate .js file for making javascript excecutable and then i simply call this js file like this.


<script src="~/Scripts/stategrid.js" type="text/javascript"></script>

Need Your Help

Is it bad practice to use entity objects across all layers of a web application?

java hibernate jpa standards

I am developing a web application using a layered architecture. I have: