{"id":504,"date":"2022-08-30T15:02:27","date_gmt":"2022-08-30T15:02:27","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/another-easy-jquery-question-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:02:27","modified_gmt":"2022-08-30T15:02:27","slug":"another-easy-jquery-question-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/another-easy-jquery-question-collection-of-common-programming-errors\/","title":{"rendered":"Another Easy jQuery Question-Collection of common programming errors"},"content":{"rendered":"<p>Your issue is just scoping. In your load() callback, this refers to the element you&#8217;re calling load() on, which happens to be <code>$('#sandbox')<\/code>, and thus: no href. Usually what I do is something like this:<\/p>\n<pre><code>$('.jNav').click(function()\n{\n  var self = this;\n  $('#sandbox').load($(this).attr('href'),function() \n  {\n    \/\/ Notice the use of self here, as we declared above\n    alert(\"From here \" + $(self).attr('href') + \" to here.\");\n    loadScript();\n  });\n  return false;\n});\n<\/code><\/pre>\n<p>Doing this ensures that you can still get to the thing that you clicked from inside the load() callback.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 20:01:40. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Your issue is just scoping. In your load() callback, this refers to the element you&#8217;re calling load() on, which happens to be $(&#8216;#sandbox&#8217;), and thus: no href. Usually what I do is something like this: $(&#8216;.jNav&#8217;).click(function() { var self = this; $(&#8216;#sandbox&#8217;).load($(this).attr(&#8216;href&#8217;),function() { \/\/ Notice the use of self here, as we declared above alert(&#8220;From [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-504","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/504","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=504"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/504\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=504"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=504"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=504"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}