Heres a problem I know a lot of people come accross. Basically you are trying to send and recieve information between a server side language and client side language.
For ajax you might have a class that sends POST or GET data with a response handler. Actually its the same with as3...
But the problem is when you recieve the response from PHP for some reason the value you get is 'undefined', or you even get a print out of the whole PHP code, or even stranger you get the whole page in the encoding formatt which basically has loads of % signs and so on.
This is an easy problem to solve but took me days to find what was causing this problem.
One early solution I had was to just assign a blank variable on the first variable and not use it, which I know is popular with a lot of people. You may have even tried it yourself.
But heres how you can avoid this messy hack.
When you get this error, your actually accessing the .php file directly, and NOT through your local server (apache for example). So for an AJAX example you might have:
postData(mydata,POST,'myPHPfile.php',responseHandler);
or for Flash AS3 you would have:
file = new URLRequest("myPHPfile.php");
All you need to do is point to this file through your server so instead of:
'myPHPfile.php' you should use:
'http://localhost/htdocs/myPHPfile.php';
or wherever you run your php scripts.
So now the as3 example will look like this:
file = new URLRequest("http://localhost/htdocs/myPHPfile.php");
Try to get those variables now and you will see it is all working! Thank F*CK FOR THAT!
Subscribe to:
Post Comments (Atom)
1 comment:
After getting very much annoyed reading about web design companies i search on the internet for a good denver web design and my search is over when i found
this site. My experience with them is fantastic.
Post a Comment