Reputation: 2451
I am new on the .NET MVC pattern and tried to call a Action using AJAX.BeginForm
Helper Class in my Controller I return seralized JSON using return JSON();
In my view I Added a Scrip witch should consume the returnes 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 am returned the Browser Shows me a Save Dialog to Save the JSON file.
Why is that?
Upvotes: 1
Views: 3948
Reputation: 21271
You've forgotten to reference jQuery. Put this inside the head of your html:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
Upvotes: 0
Reputation: 4579
I've had a similar problem, try making sure you added the references to the microsoft ajax libraries:
<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 parameter, I think it should be called "content", like this?
<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>
Upvotes: 2
Reputation: 40497
try setting content type of response to application/json as follows:
Response.ContentType = "application/json";
Upvotes: 0