i have a problem with my site that calls a php file by INCLUDE() witch connect to my server and searches my database and return html by ECHO I want to change it to JavaScript code to call that php file and the php file to return JavaScript. any idea how i can do that?
I read that it can be done if you add a header to the PHP file, so that it sends back Javascript instead of HTML. I'm not sure if this is right but here goes PHP file: <? Header('Content-Type: application/x-javascript')?> Javascript code Javascript to call the file: <script type="text/javascript" src="filename.php"></script> Code (markup):
You can do that by AJAX http://www.w3schools.com/Ajax/ajax_example.asp the example s using ASP but you can use PHP as well.