jBooker Posted April 2, 2009 Share Posted April 2, 2009 I'm VERY VERY new to AJAX, so please bear with me. Currently I'm working on a sort of CMS using PHP & MySQL for an MMORPG where users login and edit their characters and accounts. My problem is that every time the user submits a form, to update their character stats, or clicks a link, to change their characters job, the script basically updates the database and then I use header("location: ") to send them right back where they were so the information they just updated in the database is displayed on the page or to display an error. I was wondering if there is a way, or if it would be a better practice, to use AJAX to submit the form/link, update the database, and display the updated database information and error message to the user all in one go. Without the need for header();. A simple example script would help me understand, if you don't mind. Quote Link to comment https://forums.phpfreaks.com/topic/152239-ajax-to-replace-the-use-of-headerlocation/ Share on other sites More sharing options...
premiso Posted April 2, 2009 Share Posted April 2, 2009 jQuery PHP Validation Look into using jQuery framework, it makes Ajax that much easier. There are plenty examples of how to get what you are after online. Quote Link to comment https://forums.phpfreaks.com/topic/152239-ajax-to-replace-the-use-of-headerlocation/#findComment-799482 Share on other sites More sharing options...
Psycho Posted April 2, 2009 Share Posted April 2, 2009 Yes it is possible, but - in my opinion (and many others) - using AJAX (i.e. JavaScript) as the only means of doing this would be bad practice. You would be preventing the use of your site to anyone without JS enabled. Plus, you could run in to incompatability issues between how different browsers parse that JS code. That being said, I would say that implementing an AJAX solution would be a good "additional" feature. In other words, the page should work without JS enabled through normal means of a form POST but, if JS is enabled, then utilize AJAX. There are literally hundreds of tutorial on the net about AJAX. Trying to teach someone in a forum post would not make sense. Quote Link to comment https://forums.phpfreaks.com/topic/152239-ajax-to-replace-the-use-of-headerlocation/#findComment-799497 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.