Using AJAX to call PHP script
Hello there. I am planning to use an AJAX call to a PHP script that accesses a REST servlet. My php script would be very simple; something like:
<?php
// call the RESTlet to grab data from the database
$output = file_get_contents('http://localhost:xxxx');
echo $output;
?>
This is the code for my AJAX call:
$.ajax({
url: 'myscript.php',
dataType: 'json',
success: function(series)
{
// plot the data with Flot
plot = $.plot(placeholder, [series], options);
}
});
This is the error that Firefox's Error Console gives me:
"Error: no element found
Source File: file:///C:/workspace/Database/myscript.php
Line: 9, Column: 3
Source Code:
?>"
I'm an experienced programmer, but I'm fairly new to web development, so I am having trouble interpreting this error. What have I done wrong? Is this the proper way to call a PHP script with AJAX?