0

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
  • Which web-server do you use? IIS? Apache? Commented Oct 15, 2009 at 18:57

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.