1

i need to change button text from 'disable' to 'enable' or vice verse onclick depending on flag value in database which is 'on' or 'off'

i have tried to many ways using javascript and jquery but the Application methodology doesn't work with this , so i have found that the Ajax may bay the suitable way So any suggestion ?

Mohamed Nagy
  • 169
  • 2
  • 4
  • 21

1 Answers1

0

Ajax is just an asynchronous HTTP request you can perform from JavaScript (and, of course, JQuery). In fact, it stands for Asynchronous JavaScript and XML, even though JSON is preferred over XML recently.

Basically, what you could do with Ajax (using JQuery, for instance), is the following

$.get("/resource/returning/flag", function(data){
    if(data.flag == "on")
        $("button#your_button").html("disable");
    else
        $("button#your_button").html("enable");
});

Refer here for a more detailed API.

Samuele Pilleri
  • 734
  • 1
  • 7
  • 17