Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an ajax call in my js file which calls an action method returning a partial view.

This ajax call hits the breakpoint on controller for the first time it is being called. But the next time it is not hitting the breakpoint but it still goes to the success function of ajax call and the result of the success call is the complete html of the page which also includes the layout being inherited.

Could anyone please tell me what is happening here and the possible solution to this?
The js code looks like this.

var UrlRoot.History = '@Url.Action("Action", "MyController", new { Area = "ControllerArea" })';
$.ajax({
url: UrlRoot.History,
type: 'POST',
datatype: 'json',
data: params, // params being passed(which is passed correctly at the first call)
success: function (result) {
debugger;
if (result != null) {
if (result == "Please select any row from match maker to load data!!!") {
$("#NoRecord").show();
$("#NoRecord").html('');
$("#NoRecord").html(result);
}
else {
$("#tab_1").html('');
$("#tab_1").html(result); // Fill the tab content with partial view returned from action method.
}
}
},
Posted
Updated 10-Jan-15 1:52am
v2

Could you post the controller method you're calling?
 
Share this answer
 
Comments
Roliking 12-Jan-15 3:38am    
Please check my updated post for solution.
I got the solution for this problem though.


var UrlRoot = {};
UrlRoot.GetNotes = '@Url.Action("GetNotes", "MatchMaker", new { Area = "MatchMaker" })'



It was this piece of code in the partial view HTML, used to dynamically get the URL for ajax calls that caused the problem.

After moving this code into the main view solved all the problem.

Took me a lot to identity it though.

Thanks all!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900