croeltgen Posted December 29, 2010 Share Posted December 29, 2010 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 More sharing options...
dink Posted December 29, 2010 Share Posted December 29, 2010 java scriptthis 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 More sharing options...
Dilated Posted December 29, 2010 Share Posted December 29, 2010 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 More sharing options...
thescientist Posted December 29, 2010 Share Posted December 29, 2010 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.dinkno, 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 More sharing options...
ShadowMage Posted December 29, 2010 Share Posted December 29, 2010 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....followed by a colonjava script: Link to comment Share on other sites More sharing options...
dink Posted December 29, 2010 Share Posted December 29, 2010 ...followed by a colonjava script:Thank you for the information... I did not know that.. It's a perfect day when you learn something new Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.