Let's say I have in a PHP file a div called myDiv
, an image called myImg
, and a PHP variable called $x
.
When someone clicks on myImg
, I need myDiv's
text to change based on the value of $x
.
For example, let's say I want myDiv's
text to change to "Hello"
if $x==1
, and to "Bye"
if $x==2
.
Everytime the text changes, the value of $x
will change too, in this case, let's say if $x==1
when myImg
is clicked, then $x's
value will become 2
($x=2), and viceversa.
I'm using jQuery
, but I read that I need to use Ajax
too for this (To check on the server the value of $x
), but I can't figure out how to do it. I read about Ajax
, but none of the examples explains something like this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…