Jump to content

Strange onclick command


croeltgen

Recommended Posts

Hello,I came across the following line of code in a HTML:<a href="java script:void(0);" onclick='$.get("doUDID.php",{ cmd: "enable", id: "iphone" } ,function(data){ $("#enableiphone").html(data); });'>Enable</a> I cannot understand what follows the onclick=What is $ in this context? And what is the "get" about?Google wasnt really my friend for this question...Any explanation is very welcome.

Link to comment
Share on other sites

java script
this should be one word, I think
<a href="java script:void(0);" onclick='$.get("doUDID.php",{ cmd: "enable", id: "iphone" } ,function(data){ $("#enableiphone").html(data); });'>Enable</a>
It looks as if it is referencing php code in the JavaScript codeHopefully some one with more knowledge than I will give the answer.Interesting question.dink
Link to comment
Share on other sites

Hello,I came across the following line of code in a HTML:<a href="java script:void(0);" onclick='$.get("doUDID.php",{ cmd: "enable", id: "iphone" } ,function(data){ $("#enableiphone").html(data); });'>Enable</a> I cannot understand what follows the onclick=What is $ in this context? And what is the "get" about?Google wasnt really my friend for this question...Any explanation is very welcome.
$ is an alias for the core jQuery function (http://jquery.com/). When used as a function here it is returning an element using a CSS selector. The $.get function is shorthand for a GET XMLHttpRequest.So what this essentially does is, when the user clicks the link, an XHR is performed on "doUDID.php", passing the variables "cmd" and "id" to the query string (because GETs can't have request bodies). It ends up requesting: "doUDID.php?cmd=enable&id=iphone".The function that is passed in is the callback that runs when the XHR has completed successfully. It looks like it takes the data it got from the response and sticks it into an element with an @id of "enableiphone" (The .html() function acts as .innerHTML).
Link to comment
Share on other sites

this should be one word, I thinkIt looks as if it is referencing php code in the JavaScript codeHopefully some one with more knowledge than I will give the answer.Interesting question.dink
no, it's a security feature of the forum to put a space in the middle of the word javascript when it's in between code tags.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...