Go Back   Cloud Computing > Support > PHP Forum
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 12-27-10, 23:05
BOD Member
 
Join Date: Nov 2010
Posts: 202
Default Problems for AJAX

Hi!
Can anyone help me with this? I want to change Egern.net site to AJAX- but I am getting errors with PHP. I have to have PHP in the site as it is crucial to the site- and I also need to convert it to Ajax.I have problems in two areas: converting the php variables to javascript variables. the second major problem is with php blocks within the html of my site. the code is sent through XML Http Request to the JavaScript servers which send it to the main documents. the php code doesn't work properly and it is displayed as plain text. can anyone suggest what can I do?
Reply With Quote
  #2 (permalink)  
Old 12-27-10, 23:07
BOD Member
 
Join Date: Dec 2010
Posts: 227
Default

Hi!
The solution is that your PHP file should return a VALID XML to JavaScript, which in its turn parses and reads XML and view final HTML which has been made by the PHP code.

AJAX is the MIX of everything PHP, XML, JavaScript, ASP.
Reply With Quote
  #3 (permalink)  
Old 12-27-10, 23:09
BOD Member
 
Join Date: Nov 2010
Posts: 277
Default

Hi!
I see. But I want to do other thing:
In this type of our site, index.php makes a document and adds there some HTMs. Now I want to add AJAX scripts in the document, so some HTMs will be capable to be added by JavaScript. And sometimes these HTMs have PHP scripts inside.
- When they are added by index.php they normally work, because index.php is on the server and the HTMs are processed on the server.
- When HTMs are added by JavaScript PHP scripts inside them can't work, because they come through XMLHttpRequest and "enter" the document in the browser, which can't understand PHP.

Thus, these PHP scripts work only when they are processed on the server. My friend suggested to use full path in the Request (such as http://127.0.0.1/asd.htm). But it didn't help. And XMLHttpRequest object takes links to text file or XML only. I don't know how to run a PHP script on the server via JavaScript before receiving it to browser. (Maybe here is the solution...)
Reply With Quote
  #4 (permalink)  
Old 12-27-10, 23:25
BOD Member
 
Join Date: Dec 2010
Posts: 227
Default

Hi!
Have you tried renaming asd.htm to asd.php and requesting the php file.
There is a solution definitely, maybe you could give us a couple of examples I will try to ask my friends.
Reply With Quote
  #5 (permalink)  
Old 12-27-10, 23:27
Moderator
 
Join Date: Nov 2010
Posts: 476
Default

Hi!
I have tried to use php in j.-s. and j.-s. in php at same time. expl. dropdown menu. I will test your difficulty and then assist you.
And if it is possible give me that part of code for more understand.
Reply With Quote
  #6 (permalink)  
Old 12-27-10, 23:29
BOD Member
 
Join Date: Nov 2010
Posts: 277
Default

Hi!
You can select jan,
If you have PHP variable ($a), you can do this:
echo('<script type="text/javascript">var a = '.$a.'</script>');
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 01:05.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.