I am querying a PHP page (not on an external site) using $.getJSON which will return a MySQL result set, I have used json_encode() to format the result set to a JSON string. The problem is I get the data back but when I try to set the values of some hidden fields nothing happens. I had this working but now it's not. I must have changed something without realizing it. Here's the code:
jQuery:
$.getJSON('includes/Lookup.php', {locationType:$('#location').val()}, function(data) {
var valA = $('#valA');
var valB = $('#valB');
var valC = $('#valC');
$.each(data, function(index, data) {
valA.val(data.field_valueA);
valB.val(data.field_valueB);
valC.val(data.field_valueC);
});
});
Lookup.php:
<?php
$db = new MySqlDB();
if(!$db) {
// Show error if we cannot connect.
echo 'ERROR: Could not connect to the database.';
} else {
if(isset($_GET['locationType'])){
$locationType = $_GET['locationType'];
$db->where('id', $locationType);
$sql = "SELECT field_valueA, field_valueB, field_valueC FROM table";
$results = $db->query($sql);
echo json_encode($results);
} else {
echo 'not set';
}
}
This is what I get in Firebug:
<??> {"field_valueA":2,"field_valueB":3.12,"field_valueC":12345}
I don't know why <??>
is included. I am doing this exact call in two different places, on two different tables (neither are working) this is what I am getting from the other call:
<??> [{"field_valueA":905,"field_valueB":18.180000305176,"field_valueC":16453}]
If anyone has an idea as to what is going on I'd appreciate it.
EDIT: Now it seems as if ALL my ajax responses throughout my application are being prefixed with <??>
. They all worked before and now they are not, I have no idea what is going on.