![]() |
| ||
| PHP Ajax Search Hi, I'm trying to put together a PHP Ajax search against an mySQL database yet doesnt seem to work .. HELP! I had to resort to using frameset which I dont really want to do. what I'm trying to is perform a search against a mysql database and display the results on the same page. Want the ability to perform multiple search without a refresh or change of page. so far this is what i have Index.html <html> Searchuser.js var xmlHttpfunction showUser(str) The code calls a search.php which performs the search against the database and creates the tables. Search.php echos the tables using DIV . Any ideas on how to improve this ? |
| ||
| Re: PHP Ajax Search Quote:
There are a couple of syntax errors in your JS. Searchuser.js var xmlHttpfunction showUser(str) should be var xmlHttp Probably best to end all your JS commands with the semi-colon. This allows more than one on a line without having syntax errors. (Useful if you want to compress your JS also) The URL you are creating will have two ? in it. var url="search.php" I believe you want: var url="search.php"; or simpler: var url="search.php"; |
| ||
| Re: PHP Ajax Search Quote:
|
| ||
| Re: PHP Ajax Search something is wrong on this area: <form name="form" action="search.php" method="get"> what you're doing there is you're refreshing the whole page when the search button is triggered which defeats the purpose of ajax. Now you created search.js which will be responsible for contacting the search.php BUT the problem is, your interface does not call the JS FUNCTION for connecting. here's my suggestion <form name="myform"> now when the search button is click, it will call the showuser function from the javascript.... But there's still a problem, you need to pass the "NAME" to the server. At the moment the "NAME" is in the the text box and we're going to get that using javascript again.. so you might want to modify your searchUser function with something like: function showUser() you know AJAX is kindof long to explain, why dont you just follow the examples correctly provided on your tutorial? Because the way I see it you have syntax errors on your javascript.. oh and never ever do ajax if you don't know javascripting |
| All times are GMT -4. The time now is 8:01 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC