FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


server access, PHP vs AJAX






Which method is better for SQL access?
POST
100%
 100%  [ 1 ]
AJAX
0%
 0%  [ 0 ]
Total Votes : 1

HoytJolly
I would like to create a page that is able to access a database via SQL and return information based on user input. Would it be better to create a page that sends POST information to itself, or use AJAX to interact with the database without using page loads?
rickylau
POST and AJAX are not mutually exclusive, AJAX sends asynchronous HTTP request, while request type can be both POST or GET no matter of AJAX or not... For me I would first initialize the form without AJAX first (in case of AJAX is not available), if it possible then use JavaScript to interrupt the submit event, and POST it by AJAX.
Fire Boar
Why don't you just use PHP to access the database? There's no need to send a POST request to generate a page using information in a database.
jmraker
First off there's are 2 main types of HTTP requests; GET and POST. Ajax must use one of them, ajax is just a http request that is created and handled by javascript. Ajax isn't a direct connection to a database, you will need to create a web based program for the database connection and the SQL stuff.

For me the first time I did an ajax form submit it was weird because it didn't show any indication the submit button was doing anything. So I had to add that in. Good Ajax requires some extra javascript to handle user interface stuff like that and code for aborting the connection after so many seconds because sometimes the ajax call never triggers a success or fail function.
Nemesis234
well considering they both do kinda the same thing when interacting with a DB, it just depends if you care the users screen has to refresh or not. so its really your choice.

ajax would be better, less server load, quicker for user, whether you can be bothered or not is another thing.
PureReborn
I recommend using Ajax for front end user interface and PHP for back end DB query. Javascript can be viewed by users (since it's client side) while PHP code can't (already executed by server).

Just safer overall, no need to show the sql queries to the user.
Nemesis234
PureReborn wrote:
Just safer overall, no need to show the sql queries to the user.

huh? what language actually shows the queries to the user??
sonam
HoytJolly wrote:
I would like to create a page that is able to access a database via SQL and return information based on user input. Would it be better to create a page that sends POST information to itself, or use AJAX to interact with the database without using page loads?


The both system is OK independent for what you need it. For example, if you have some game or gallery, more then one query to SQL and you think the reloads will irritate users then is better to use ajax. If you need only one-two queries (to display user name, birthday, etc.) then it is better to use PHP without Ajax.

Sonam
Related topics
php admin and mysql admin console
[PHP] Faking Shell Access Through PHP
PHP-Server at localhost
PHP VS ASP
make a server - with php and MySQL
server with ready PHP
access active directory ldap server with php
Apache server with php???
PHP&Ajax Trke karakter sorunu
Running PHP Script without PHP Server?
Server 2 PHP info (need fast PLEASE)
upload image through PHP AND AJAX
php vrs ajax
php and ajax
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.