jquery - How to get button value by ajax -


I'm getting button values ​​by Ajax. I have 4 buttons with other values ​​

  & lt; Button Type = "Button" value = "Today" onclick = postdata class = "btn BTN-Primary BTN-LG" & gt; Today & lt; / Button & gt; & Lt; Button type = "button" onclick = postdata value = "week" class = "btn btn-primary btn-lg" & gt; Week and lieutenant; / Button & gt; & Lt; Button Type = "Button" value = "month" onclick = postdata class = "btn BTN-Primary BTN-LG" & gt; Today & lt; / Button & gt; & Lt; Button Type = "Button" onclick = postdata value = "year" class = "BTN BTN-Primary BTN-LG" & gt; Week and lieutenant; / Button & gt; Function PostData (link) {$. Ajax ({url: link, type: "POST", data: {date: $ ('button'). Val ()}}}}   

onclick me always the value of the first button Can anyone tell me how to get the button clicked by Ajax?

itemprop = "text">

Change onclick = postada to onclick = postada (this)

and then:

  function postdata (link) {$ .ajax ({url: link, type: "POST", data: {date: $ (link) Val ();}}}}   

Notice: I do not recommend about the way you are doing this, I like the binding: < P> $ ('botton'). ('....

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -