Hopefully this makes sense... but I am trying to write some initial ajax call to a test php page and i am getting an error within the console that reads:
Uncaught Error: Syntax error, unrecognized expression: {"projectId":"John","Project":"Some Project Name"} jquery-1.9.min.js:4
st.error jquery-1.9.min.js:4
ft jquery-1.9.min.js:4
wt jquery-1.9.min.js:4
st jquery-1.9.min.js:4
b.fn.extend.find jquery-1.9.min.js:4
b.fn.b.init jquery-1.9.min.js:3
b jquery-1.9.min.js:3
(anonymous function) download.js:27
c jquery-1.9.min.js:3
p.add jquery-1.9.min.js:3
(anonymous function) download.js:25
b.event.dispatch jquery-1.9.min.js:3
v.handle jquery-1.9.min.js:3
This is my jquery ajax call:
$.get('test.php', {object_ID: 'kjiyu-drtfg-hjuyt-hiytr'})
.done(function(data) {
console.log(data);
$(data).each(function(index, element) {
$('#fileList').append('<option value="' + element.projectId + '">' + element.Project + '</option>');
});
});
This is my test.php page:
<?php
echo json_encode(array(
array("projectId"=>"John","Project"=>"Some Project Name"),
array("projectId"=>"John2","Project"=>"Some Project Name 2")
));
?>
any advise would be greatly appreciated. In the end this will be hooked up to an actual page that looks up values from the database... I just want to get my first round going.
EDIT
I made the array change suggested but am now getting this error:
XMLHttpRequest cannot load file:///C:/Users/v-sthaff/Documents/School/Spring%202013/BIT%20286/Website/test.php?object_ID=kjiyu-drtfg-hjuyt-hiytr. Origin null is not allowed by Access-Control-Allow-Origin. jquery-1.9.min.js:5
send jquery-1.9.min.js:5
b.extend.ajax jquery-1.9.min.js:5
b.(anonymous function) jquery-1.9.min.js:5
(anonymous function) download.js:24
b.event.dispatch jquery-1.9.min.js:3
v.handle
XMLHttpRequest cannot load file:///C:/Users/v-sthaff/Documents/School/Spring%202013/BIT%20286/Website/test.php?projectId=abcde-abcde-abcde-abcde. Origin null is not allowed by Access-Control-Allow-Origin. jquery-1.9.min.js:5
send jquery-1.9.min.js:5
b.extend.ajax jquery-1.9.min.js:5
b.(anonymous function) jquery-1.9.min.js:5
(anonymous function) download.js:43
b.event.dispatch jquery-1.9.min.js:3
v.handle
EDIT - SOLUTION: Moving the files up to my server seemed to solve the problem as well as this updated jquery:
$.getJSON('test.php', {object_ID: 'kjiyu-drtfg-hjuyt-hiytr'})
.done(function(data) {
console.log(data);
$(data).each(function(index, element) {
alert(element.projectId + ' ' + element.Project);
$('#fileList').append('<option value="' + element.projectId + '">' + element.Project + '</option>');
});
});