I want to be able to display the following code below only when a user clicks a specific link. Is it possible with JQuery? If so how would I be able to do this?
Here is my code.
function signedIN(){
$.ajax({
type: "GET",
url: "http://update.php",
data: "do=getID",
cache: false,
async: false,
success: function(result) {
$("#status").text(result);
},
error: function(result) {
alert("some error occured, please try again later");
}
});
}
Given a link with an ID of
update:Bind your
signedIN()function to the link’s click event:You’ll need to add a
return false;at the end of your function so the link doesn’t actually proceed toupdate.php(the link’shrefvalue).EDIT: here’s a more complete code example so you can see how this all comes together: