Can some one help or explain to me how this works please?
i have in my view:
<script type="text/javascript">
var jqxhr = $.getJSON("<%= Url.Action("GetTrainingModulePoints" , "Home") %>", function (json) {
console.log(json);
});
</script>
GetTrainingModulePoints should return 4 rows each containing a value for interactiontype and a value for points
in the console log i just get [object object]?
how can i see what is in the variable json?
http://imageshack.us/photo/my-images/542/firebug.png/
thanks
Look at the
Network tab in FireBugor similar javascript debugging tool. There you will see the AJAX request and all you have to do is expand the request and look at the response.Here’s for example how that might look like in FireBug for a sample AJAX request:
And if you click on the
JSONtab you will see the output formatted as a JSON object where you could expand/collapse the properties.If for some very weird reason you cannot use a javascript debugging tool in your web browser (I don’t know even know how you could be developing a web application, but …) you could use the
JSON.stringifymethod that’s built into modern browsers:And if you are not using a modern browser which doesn’t have the
JSON.stringifymethod natively built-in you could still reference the json2.js script to your page.UPDATE:
OK, it seems that your confusion comes from the fact that you are getting
{"success":true}whereas you were expecting to get the rows from your stored procedure. I know this because I answered yourprevious question.Here’s how your controller action look like:
As you can see in this controller action you are always returning
success = true. If you want to return the results from your stored procedure you could do this:Here I assume that your
TrainingService.GetTrainingModulePointsmethod is actually returning some object. If this is not the case you will have to explain what those methods are doing and how do you expect to get the output.