The scenario:
Sending search criteria to the server using json / Ajax in jquery .. the ajax call should simply end there and not expect anything back (e.g. Simply post the Json data and stop ) ..
What is happening:
The data is being sent, but the returned data is also being received by the ajax call :
The code:
public ActionResult GetBasicSearchResults(BasicSearchCriteriaInfo basicSearchCriteria)
{
List<BasicSearchResult> results = _client.GetBasicSearchResult(basicSearchCriteria).ToList();
return View("BasicSearchResult",results);
}
The Ajax call:
$.ajax({
url: url,
type: 'post',
data: JSON.stringify(basicSearchCriteria),
dataType: 'json',
contentType: 'application/json;',
success: function () {
}
});
The ActionResult should render a new View based on the Received data but is sending the data back to the Ajax method. Kindly guide for possible approach.
The main aim is to only send the Data as JSON to the server and nothing else.
Thank you for the suggestions .. Have used the following approach to solving the issue..
When the data is received by the server, it processes it and saves it in TempData variable and send a true boolean as JSON back to the ajax call.
The Ajax call (upon receiving a true) then requests a new Action Method (using window.location) . That action method then uses the TempData variable to get the object and send to a Strongly Typed view for appropriate processing ..
Thanks again 🙂