tags:

views:

23

answers:

3

Hello, I'm dynamically loading different content from db, using ajax.

So, when I'm loading plain text - it shows correctly, but when there is a php-script in content, it wouldn't be interpreted by php-server, so I can see a code at the page. Could I load php script like this way?

+1  A: 

You have a server setting issue. whether you Ajax a file or pull it in directly in the browser, the server sees the request the same way. You need to tell your web sever to parse php files not serve them.

Byron Whitlock
A: 

I'm dynamically loading different content from db, using ajax

You can't directly query the database using javascript, you are probably posting to some server side script which in turn talks to the database and returns the result in some form (XML, JSON, plain text). If I understand correctly from your description you have a php-script stored in the database which you want to execute on the server and return the result of this execution to the client. One way you could achieve this is to have a php-script which queries the database, evals the content and returns the result as plain text.

Darin Dimitrov
+1  A: 

This is web-server misconfiguration. You should look at php installation instruction. If you are using Apache2 server, then you should add following line in your httpd.conf:

AddHandler application/x-httpd-php .php

Make sure that you have mod_php5 loaded.

Ivan Nevostruev