Got some basic problem again.
I need to modify a function that previously returned a in code written object. Im now trying to get the object from json through $.getJSON
function getEventData() { var result = ''; $.getJSON("ajax.php?cmd=getbydate&fromdate=&todate=", function(data) { result = data; }); return result; } Problem is that result isn't set in the callback function for obvious reasons.
Do you guys have a solution for this?
Edit: Ok i got an answer that was removed. I just had to change it abit..
This is the answer that works:
function getEventData() { var result = ''; url = "ajax.php?cmd=getbydate&fromdate=&todate="; $.ajax({ url: url, async: false, dataType: 'json', success: function(data) { result = data; } }); return result; }