I am trying to pass a variable to an ajax request via jquery. I have a triggered event that defines the variable. I want to do this so that I can have one ajax request handle multiple urls. I have alerted the url and it come back fine, but when I plug it into the URL slot of a $.ajax request my targeted content does not load. Here is my code.
$(document).ready(function(){
$('a').live('click', function(){
var link = $(this).attr("href");
$.ajax({
url: link,
success: function(html){
$('#load').html(html)
}
});
});
});
this has been a real headache and I feel I am just misusing something. Please help.
There is a shortcut for this using
.load()🙂Be aware of the same origin policy that Justin is alluding to as well, requests to different domains are prohibited for security reasons.