Reputation: 1990
i have been learning about javascript and using dojo. I am trying to execute a php file with dojo. My code is
dojo.xhrGet({
url: 'helloworld.php',
load: testCallback,
error: testError,
content: {name: dojo.byId('name').value}
});
for the dojo function. The php file is basically a simple script that prints the value of whats being passed in through xhrGet
<?php
header('Content-type: text/plain');
print "Hello {$_GET['name']}\n";
?>
When I call this function, I get the php file displayed as text. My testCallback function is simply
function testCallback(data, ioArgs)
{
alert("in testCallback");
alert(data);
}
I cant think why this wont work as it was pulled from the dojo tutorial itself. I tested php with a file with phpinfo() in it, and it was working. Does php have to be configured to 'work' with certain ports?
Upvotes: 0
Views: 141
Reputation: 5839
If you get your php file back as text your webserver is not setup to call php to handle the file. It is as simple as that.
Have you named it .php or something else (judging from the post it looks like it is called helloworld.php and in that case I wonder how your phpinfo() call could work, was it the same server?)
Upvotes: 3