I have successfully returned a JSON object/array(not too good with terminology), using the below code.
$(function(){
$("#buildForm").click(function(e){
e.preventDefault();
var frm = $(document.buildForm);
var dat = JSON.stringify(frm.serializeArray());
$.post(frm.attr("action"), {data:dat}, function(response)
{
var $dialog = $('<div></div>')
.html(response)
.dialog({
autoOpen: false,
title: 'Build',
modal: true,
height: 400
});
$dialog.dialog('open');
// prevent the default action, e.g., following a link
return false;
});
});
});
It returns
{"str_id":"1","str_name":"TC","tier_id":"1","buy_gold":"50000","buy_mana":"10000","res_build":"0","res_active":"0","res_owned":"0","timebuildmins":"500","timecollectmins":"30","timeminsformiss":"0","goldcollected":"1000","str_imageloc":"..\/img\/structures\/tc.png"}
I don't know much JS, but im trying to learn by doing. Unfortunately, I can't figure out how to simply display, for instance, only the "str_name."
As you can see, I have a popup window from the jquery ui open to display the retrieved data in JSON format. I need to be able to take bits of the returned data and display it! Simple right? Please help!