3

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

2
  • if you plan to call this by AJAX, there is no need for a html tag if you do not want to load in into an iframe Commented Jun 25, 2013 at 11:53
  • Thanks a lot, I have only few products that loads by AJAX, other than that every other part is ECHOed by PHP Commented Jun 25, 2013 at 13:40

1 Answer 1

2

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

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

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.