I am attempting to get a link to fire JQuery's .click() function so that I can call another script behind the scenes. All of the JQuery is generated dynamically by PHP.
The code looks correct, but the .click is not firing.
This is the code that generates the jquery:
$jscript = "$(\"".$server ."Restart\").click(function()
{
$.get(\"modules/test.php\", {command: \"RESTART\", server: \"$server\"},
function(data){
alert(\"Data Sent: \" + data);
}
);
});
";
This is the code as it looks after generation (with just an alert right now because I can't get it to do anything):
$("critRestart").click(function()
{
$.get("modules/test.php", {command: "RESTART", server: "crit"},
function(data){
alert("Data Sent: " + data);
}
);
});
This is the link that is clicked on that should be firing that event: <div id="critRestart"><a href="#">RESTART</a></div>
Can anyone help?
You need a #
in an #id
selector, like this:
$("#critRestart").click(function() {
Without the #
, it's looking for a <critRestart>
element (an element selector).