Hi,
I am trying to use Jquerys getJSON method to return data server side to my browser, what happens is the url the getJSON method points to does get reached but upon the postback the result does not get returned to the browser for some odd reason. I wasen't sure if it was because I was using MVC 2.0 and jQuery 1.4.1 and it differs to the MVC 1.0 version and jQuerys 1.3.2 version. . this is the code sections
Controller
public JsonResult StringReturn() {
NameDTO myName = new NameDTO();
myName.nameID = 1;
myName.name= "James";
myName.nameDescription = "Jmaes";
return Json(myName);
}
View with JQuery
<script type="text/javascript">
$(document).ready(function () {
$("#myButton").click(function () {
$.getJSON("Home/StringReturn/", null, function (data) {
alert(data.name);
$("#show").append($("<div>" + data.name + "</div>"));
});
});
});
</script>
HTML
<input type="button" value="clickMe" id="myButton"/>
<div id="show">d</div>