Returning ASP.NET MVC JSON () shows me the Save File dialog
I am new to .NET MVC pattern and tried to call Action using a AJAX.BeginForm
helper class in my controller. I am returning seralized JSON using return JSON ();
In my opinion, I added a Scrip that should absorb the return of JSON.
function ResultSet(request) {
var json = content.get_response().get_object();
var result = eval(json);
if (result.Successfull) {
alert("Success!");
}
else {
alert("else");
}
}
But instead, if I go back, the browser shows me a save dialog to save the JSON file.
Why is this?
+1
a source to share
3 answers
I had a similar problem, try for you to add links to the ajax libraries for Microsoft:
<script src="/Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcAjax.debug.js" type="text/javascript"></script>
also. your ResultSet () method takes a variable named "request" as a parameter, I think it should be called "content" like:
<script type="text/javascript">
function ResultSet(content) {
var json = content.get_response().get_object();
var result = eval(json);
if (result.Successfull) {
alert("Success!");
}
else {
alert("else");
}
}
</script>
+2
a source to share