Hi folks,
I'm a long time lurker, part time poster here - have been having a nasty issue to do with dispatching Ajax requests.
Note that I am using asynchronous Ajax requests here.
Given the code in a .page:
<script language="javascript" type="text/javascript">
function performActionOnObjectID(objectID, actionType) {
var request = <%=$this->callbackAction->ActiveControl->Javascript %>;
request.setCallbackParameter({'action':actionType, 'id':objectID});
request.dispatch();
}
</script>
<com:TCallback ID="callbackAction" OnCallback="callback_Action" EnableViewState="true">
</com:TCallback>
<a href="javascript:performActionOnObjectID(27,'approve');">approve 27</a><br />
<a href="javascript:performActionOnObjectID(28,'approve');">approve 28</a><br />
<a href="javascript:performActionOnObjectID(29,'approve');">approve 29</a> <br />
<a href="javascript:performActionOnObjectID(30,'approve');">approve 30</a> <br />
<a href="javascript:performActionOnObjectID(31,'approve');">approve 31</a> <br />
<a href="javascript:performActionOnObjectID(32,'approve');">approve 32</a> <br />
<a href="javascript:performActionOnObjectID(33,'approve');">approve 33</a> <br />
<a href="javascript:performActionOnObjectID(34,'approve');">approve 34</a> <br />
<a href="javascript:performActionOnObjectID(35,'approve');">approve 35</a> <br />
<com:TJavascriptLogger />
I would expect the output in my Javascript logger or Firebug to show the ID# passed in the "performActionOnObjectID" - ie. one of 27, 28, 29, etc, given the following handler (.php):
public function callback_Action($sender, $param)
{
$theAction = '';
$theID = -1;
if ($param->CallbackParameter)
{
if ($param->CallbackParameter->action)
{
$theAction = $param->CallbackParameter->action;
echo "THE ACTION=".$theAction;
}
if ($param->CallbackParameter->id)
{
$theID = intval($param->CallbackParameter->id);
echo "THE ID=".$theID;
}
}
}
Most of the time the ID number of the link I clicked on in the .page appears in my logger/firebug - BUT SOMETIMES, SOMETHING GOES REALLY WRONG!
When you click on ALL of the links only ONCE (27 through to 35), one after the other as quickly as possible, the Ajax queue "enqueues" each of the ajax callback requests, and sends them off sooner or later. But instead of the debug output in my logger/firebug showing something like 27,29,35,32 etc (ie. each ID number only once), often it will show a result like 27,28,35,35,35,35 etc.
It appears that the queued callbacks after the first two or three ajax requests have their parameters overwritten in memory (on the client side I suspect - perhaps within ajax3.js or activecontrols3.js) which causes the above behaviour to take place.
Has anyone else noticed this issue? Even though i am running PRado 3.1.2 i have checked the svn repo and not much appears to have changed in ajax3.js or activecontrols3.js)
A desperate dilletente awaits your assistance!
-Damo