Saturday, 15 August 2015

jquery - Ajax PHP updation not working -


I am trying to update a field through ajax which is not working. Below is code

Jquery:

  & lt; Script type = "text / javascript" & gt; Function changestats (changestats, user id) {var data = "changestats =" + changestats + "and user id =" + user id; $ .ajax ({type: 'gET', url: 'myfans.fp', data: data, success: function (alerts ('updates');}}); } & Lt; / Script & gt;   

php:

  & lt ;? Php function changestats ($ changeStatus, $ userId) {$ userId = $ _GET ['userId']; $ UserStatus = $ _ Received ['userStatus']; Switch ($ user status) {case "1": $ changeStatus = 0; break; Case "0": $ changeStatus = 1; break; Default: $ changeStatus = ""; } $ Query = "update blog_user SET blog_user_status = '$ changeStatus' WHERE blog_user_idie = '$ user id'"; $ Result = mysql_query ($ query); } If (isset ($ _GET ['userId']) and release ($ _GET ['userStatus'])) {changeStatus ($ changeStatus, $ userId); }? & Gt;   

And here's how I call functions:

  & lt; A href = "#" onclick = "changeStatus ($ changeStatus, $ userId)" & gt; & Lt ;? Php ek $ action; ? & Gt; & Lt; / A & gt;   

Just to know that I have tried it only in the PRP so that you can get value through href. And it was working ...

  & lt; A href = "#" onclick = "ChangeStatus (& lt ;? php echo $ changeStatus;? & Gt; & lt; php echo $ userId ;; & gt;)" & gt; & Lt ;? Php ek $ action; ? & Gt; & Lt; / A & gt;   

Try it with

No comments:

Post a Comment