开发者

Ajax - loadable php-script

开发者 https://www.devze.com 2022-12-08 20:47 出处:网络
I\'m dynamically loading different content from db, using ajax. So, when I\'m loadin开发者_JAVA技巧g plain text - it shows correctly, but when there is a php-script in content, it wouldn\'t be interp

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

So, when I'm loadin开发者_JAVA技巧g 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?


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消