Hi,
I am new to Jquery and want to know why this script is not working.
getfield.php :
$data['value1'] = "this is value 1";
$data['value2'] = "this is value 2";
echo "$data[value1] <|> $data[value2]";
the jquery script:
$.get('getfield.php',
function(result){
alert("Data Loaded: " + result);
});
//split the returned value
var extracted=result.split("<|>");
$("#val1").text(extracted[0]);
$("#val2").text(extracted[1]);
the alert window showing : (as expected)
Data Loaded: this is value 1 <|> this is value 2
but if I change the getfield.php so value1 and value2 is get from a record of a database :
.. //get record from database, where $rec is an array of a record
$data['value1'] = $rec[name];
$data['value2'] = $rec[address];
echo "$data[value1] <|> $data[value2]";
the alert window showing :
Data Loaded: <|>
I want to fill the result to :
<div id="val1"></div>
<div id="val2"></div>
I found a solution using getJSON but my php version is 5.1 and json is not installed.