I am trying to load a dynamic URL generated by Python Django using jQuery.
$('a').click(function(ev) {
ev.preventDefault();
var url = $(this).attr('href');
$('#loadDiv').load('localhost/home/{{ movie.id }}/add_question/');
});
How can I catch and load the link if it constantly changes?
If you create your template in a sensible manner, each link found therein will have a different link matching the item for that element. Assuming a named url called
movie_add, taking a single parameter being the movie ID, make your template like this:Now each
atag will have a url that lets you add a question for that specific movie. From there on, the following script should do what you want: