Another Easy jQuery Question-Collection of common programming errors

Your issue is just scoping. In your load() callback, this refers to the element you’re calling load() on, which happens to be $('#sandbox'), and thus: no href. Usually what I do is something like this:

$('.jNav').click(function()
{
  var self = this;
  $('#sandbox').load($(this).attr('href'),function() 
  {
    // Notice the use of self here, as we declared above
    alert("From here " + $(self).attr('href') + " to here.");
    loadScript();
  });
  return false;
});

Doing this ensures that you can still get to the thing that you clicked from inside the load() callback.

Originally posted 2013-11-09 20:01:40.