Hello I am trying to communicate my view to my ajax script.
urls.py
from .views import (
video_testimonial,
)
urlpatterns = [
url(r'^(?P<id>\d+)/video_testimonial/$', video_testimonial, name='video_testimonial'),
]
So basically it requires an integer in order the url can be access.
e.g 0/video_testimonial/
Here's my
views.py
def video_testimonial(request, id):
testimonial = Testimonial.objects.filter(id=id)
if request.is_ajax():
context = {
'testimonial': testimonial,
}
return JsonResponse(context)
else:
raise Http404
my script (internal script) in my html:
presentation.html
function showVideoTestimonial() {
var id = parseInt($('.carousel-inner a').attr('id'));
$.ajax({
url: id +'/video_testimonial/',
success: function (data) {
console.log(data.testimonial);
$('.carousel-inner a').click(function () {
console.log(id);
});
}
})
}
showVideoTestimonial();
url: id +'/video_testimonial/', am i missing something accessing the url? thanks for responding