Nov 22, 2009

Integrity Checks Failing During Multiple Ajax Request - somehow the checks fail due to lag.

free web hosting
Open Discussion > MODERATED AREA > Computers > Programming Languages > AJAX

Integrity Checks Failing During Multiple Ajax Request - somehow the checks fail due to lag.

sonesay
Heres my merit system at its current stage. http://sonesay.trap17.com/index.php
note: select a character from the drop down list to see output.

I've been working on this locally on my mac and because of little or no delay I did not see the problem until I decided to upload to the WWW. The problem lies in the adding of merits to each category. Although there are integrity checks on the PHP side before executing the update to mysql database it somehow fails because of the lag.
i.e multiple 'add' buttons can be pressed before the section gets reloaded. so if your modifying the 'Combat Skill' category and its 19/20 you should only be able to add one more merit. But because of page reloading delay you are able to hit more buttons before it finishes reloading.

my function to modify merits.
CODE
function modify_merit($mm_c_id, $mm_mode, $mm_merit, $mm_combo_limit, $mm_item_limit, $mm_table) {
include('../db.php');

if ($mm_mode == "remove") {
// check if merit is equal or above 1 before lowering by 1
// get users merits
$q1 = "SELECT ".$mm_merit." FROM ".$mm_table." WHERE c_id = ".$mm_c_id;
$r1 = mysql_query($q1, $link);
while ($m = mysql_fetch_array($r1)) {
$mm_new_level = $m[$mm_merit];
}
if($mm_new_level > 0) {
$mm_new_level--;
// update hp level
$q2 = "UPDATE ".$mm_table." SET ".$mm_merit." = ".$mm_new_level . " WHERE c_id = " . $mm_c_id;
mysql_query($q2, $link);
}
}
if ($mm_mode == "add") {
$q1 = "SELECT ".$mm_merit." FROM ".$mm_table." WHERE c_id = ".$mm_c_id;
$r1 = mysql_query($q1, $link);
while ($m = mysql_fetch_array($r1)) {
$mm_new_level = $m[$mm_merit];
}
// check if under max combo and item limit before adding.
if($mm_new_level < $mm_item_limit && $mm_new_level < $mm_combo_limit) {
$mm_new_level++;
// update hp level
$q2 = "UPDATE ".$mm_table." SET ".$mm_merit." = ".$mm_new_level . " WHERE c_id = " . $mm_c_id;
mysql_query($q2, $link);
}
}
}


each button pressed is added like this
CODE
if($merit == "sword_level") {
modify_merit($c_id, $mode, $merit, 20, 8, 'combat_skill');
}



I know I cant blame lag being the cause of my problem its my code. There are two options at this stage I can think of

1. Redo all the sections and reload all Div's in the same category all at once so there is no way to press more then 2 buttons. e.g if HP merit is incresed the whole HPMP div reloads at once so there is no chance to hit the add MP button causing 8 max combo constraint to fail.

2. Use java script to disable all add buttons in the category being modified until its fully reloaded(not sure this will work).

What do you think would be the best way to fix this?

 

 

 


Comment/Reply (w/o sign-up)

moodsey211
I think the second one will work.

Comment/Reply (w/o sign-up)



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords : integrity, checks, failing, multiple, ajax, request, checks, fail, due, lag,

  1. Best Ajax Sites
    (5)
  2. Problems With Trying To Validate Ajax Called Html
    (3)
    I've been validating my site on http://validator.w3.org so far so good but what I'm
    interested in is validating my page that has been modified by Ajax requests. Viewing the source code
    afterwards wont show the new code in Firefox and its the same for other browsers I believe(yes I
    have tried and cant remember ever seeing the newly inserted HTML in the source code). I'm
    certain my code is not going to be valid there because I've hacked away at getting it to work
    and its very long so there are bound to be mistakes hence the reason why I would want to va....
  3. Ie 7 Issue With Ajax
    Some ajax calls dont seem to work (2)
    function reload_char() { race_id = Ext.get('race').dom.value; gender =
    Ext.get('race_gender').dom.value; face = Ext.get('race_face').dom.value; hair_id =
    Ext.get('race_hair').dom.value; // race race_letter =
    Array('H','E','T','M','G'); race = race_letter ; /*
    //gender if(race == 'G' || race == 'M') { gender = ''; } //hair
    if(hair_id == 1) { hair = 'a'; } else { hair = 'b'; } image =
    '80px-'+race+gender+face+hair+&....
  4. Zk
    the number 1 Ajax Framework (2)
    ZK is an open-source Ajax Web framework that enables rich user interface for Web applications with
    little programming. Its an event-driven, component-based framework to enable rich user interfaces
    for Web applications. ZK includes an AJAX-based event-driven engine, a rich set of XUL and XHTML
    components and a markup language called ZUML (ZK User Interface Markup Language). With ZK, you
    represent your application in feature-rich XUL and XHTML components and manipulate them upon events
    triggered by user's activity, similar to what is done in desktop applications. Un....

    1. Looking for integrity, checks, failing, multiple, ajax, request, checks, fail, due, lag,

Searching Video's for integrity, checks, failing, multiple, ajax, request, checks, fail, due, lag,
See Also,
advertisement


Integrity Checks Failing During Multiple Ajax Request - somehow the checks fail due to lag.

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com