Topic: avoid double invocation of a page
Hi all, it's the first time I post here, today I went trough an issue that take me some effort.
I wrote a php page (let say index.php) that fulfill different kind o actions depending on the value of 'action' parameter (i.e. index.php?action=new does something different than index.php?action=edit). This page use xajax capabilities to list items the user can search. My main trouble is that my xajax_listItems() method that is invoked as soon as the page is loaded cause the index.php page to be invoked again. As you may figure when I invoke index.php?action=new I don't want that action to be performed again becouse new objects will be created in the db.
The only answer I found is to detect which method is used by the request:
Code: PHP
if ($_SERVER['REQUEST_METHOD']=='GET'){...} else {...}
in facts i noticed that while I'm invoking index.php with get method xajax will use post.
I hope that someone will find this post usefull. Maybe someone can suggest a better answer.
Last edited by marco.gonnelli (2010-03-11 4:43:06 PM)