Msg#: 4358934 posted 1:33 am on Sep 6, 2011 (gmt 0)
After struggling with Ajax for a few years, I hunkered down and finally got into it. Not as difficult as it first seemed.
I do have one question regarding opening and closing the MySQL database.
Main Program openMysqlDbFunction; do some assorted stuff Do the Ajax thing do some db stuff close database
PHP called by Ajax do some db stuff
This will give me an error because the database is not opened.
PHP called by Ajax openMysqlDbFunction; do some db stuff
1) Why do I have to open it again even though it's open in the main calling program? 2) Because I'm opening it again in the Ajax PHP code, does that close the DB in the main program? 3) Suppose the Ajax routine is called several times in the Main Program. Am I not doing things cleanly? Should I close the DB in the Ajax/PHP code?
Msg#: 4358934 posted 8:17 am on Sep 6, 2011 (gmt 0)
Why do I have to open it again even though it's open in the main calling program?
If I get you right, you mean "the page containing the ajax" when you say "main program." So this (PHP?) page opens a connection, outputs the data, closes connection. Your Ajax request, then, is like a separate "page" being called, it has to re-open a new connection to do "whatever." And when it's done, it closes again.