Question

I was developing a web application

I am building the PHP part now and I have planned to build the script / AJAX part in the future. like adding sort/category option using AJAX to the application.

Below is how my syntax is

<?php open-connection();?>

    <html> 
         Some html part with sort option
         <script>script part and some AJAX part </script>
    </html>


<?php ob_flush and Close-mysql-connection ?>

will my Ajax /script part works that has access to database depending on the user.

I think after the close connection establishing the ajax will not work. Please guide me.

thanks in advance

Was it helpful?

Solution

An ajax call will open a new HTTP connection by it self. It is no different than an ordinary request to your server in terms of connecting. Bare in mind though, that you need to initialize connections to databases again in the script that is to be called dynamically because, as I said, it is treated as a separate request, which it actually is, therefore you need to re-initialize everything that you need to use.

Best of luck! :P

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top