I've prepared an array in php for ajax return with json_encode. When returned through ajax, it is not behaving as I expected.
ajax call and my attempt to interrogate results
$.ajax({
url:"dbpaginate.php",
type:"POST",
data: {'environmentvars': tmp},
cache: false,
success: function(response){
alert('Returned from ajax: ' + response);
alert(response["actionfunction"]);
$j.each(response, function (index,element) {
alert(index);
alert(element);
});
});
first alert message:
Returned from ajax: array(5) {
["actionfunction"]=>
string(8) "showData"
["sortparam"]=>
string(6) "ticker"
["sortorder"]=>
string(3) "ASC"
["page"]=>
int(1)
["htmlstring"]=>
string(0) ""
}
{"actionfunction":"showData","sortparam":"ticker","sortorder":"ASC","page":1,"htmlstring":"","htmltext":"<table id=\"summaryheader\"> [...lots of html...]<\/div>\n"}
Second alert message
undefined
Expected result
showData
How can I effectively port my json response
into a javascript object environmentvars? Thanks.