0

I Have list confirmation buttons generated dynamically using PHP.When I click a button i want it change to "approved".But it is not doing so?Nothing changes though the query is submitted successfully.Any help please.Here is my js code snippet:

function appr ($ref) {
  var job_id= $ref;
  var resp;
  var buttons=$('.confirm');
buttons.click(function(){
  var $this=$(this);
  $this.text=('approved');
});            
 if (window.XMLHttpRequest) {
    resp = new XMLHttpRequest();
} else if (window.ActiveXObject) { 
    resp = new ActiveXObject("Microsoft.XMLHTTP");
}
var data = "job_id="+job_id
     resp.open("POST", 
      "approve.php",
       true); 
     resp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
     resp.send(data);
   resp.onreadystatechange = display_data;
  function display_data() {
   if (resp.readyState == 4) {
      if (resp.status == 200) {
        document.getElementById("myDiv").innerHTML=resp.responseText;  

     } else {
        alert('Request not successful.');
      }
     }
  }

}
Colo
  • 87
  • 2
  • 15

1 Answers1

1

you can do it like that

$this.html("approved");
Özgür Ersil
  • 6,909
  • 3
  • 19
  • 29