1

when i click on a button that tries to modify the session's value on serverside, it runs very well:

$('#btn1').click(function() {
   update_session('session.php?session=1');
});

But when i tried to trigger this button from another button:

$('#btn2').click(function() {
   $('#btn1').click();
});

At that moment, the session isn't changed. I really don't understand because i saw in firebug that there was a POST to server by ajax with the correct arguments.

Charles
  • 50,943
  • 13
  • 104
  • 142
Trong Lam Phan
  • 2,292
  • 3
  • 24
  • 51
  • If there was a POST to the server, the client-side code works well. Then, the problem must be server side and it has nothing to do if you clicked the element or used `.click()`. – Oriol Sep 29 '13 at 01:22

1 Answers1

1

The problem may be caused by the fact that .click() does not execute the href attribute of an anchor tag.

Having it this way should work:

var clicked = function() {
   update_session('session.php?session=1');
};
$('#btn1').click(clicked);
$('#btn2').click(clicked);

If it didn't work it is very likely a server side problem (as suggested by Oriol).

Community
  • 1
  • 1
Archy Will He 何魏奇
  • 9,589
  • 4
  • 34
  • 50