Jump to content
MakeWebGames

Ajax


Recommended Posts

Okay so I have no experience with Ajax whatsoever, how would I stop a page from bringing up the "Confirm Form Resubmission"?

Like say I have someone training, and they're trying to do it as fast as possible to keep from wasting supplies. How would I get it to repost the data but not have to hit ok while doing it? Any help would be much appreciated. Thanks.

Link to comment
Share on other sites

You do not need to use AJAX. A simple method is to use session based "flash messages". Just a simple example:

In your file that handles the form:

 

<?php
// handle form stuff here
$_SESSION['FLASH'][] = array('type'=>'success', 'message'=>'Your success message');
?>

 

& then in your template somewhere you could use this:

 

<?php
if(count($_SESSION['FLASH'])) {
   foreach($_SESSION['FLASH'] as $m) {
       echo '<div class="message-'. $m['type'] .'">'. $m['message'] .'</div>';
       unset($m);
   }
}
?>

 

I didn't test that code and theres probably a ton of logic errors but it was an example. If you are going to use something like that website wide however i'd suggest you write an API for it. Nothing fancy really.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...