Search code examples
ajaxdjangowistia

django using ajax in wistia


I build my django app to get watch video time.

I reveive data from wistiaApi and comfirm the video time from alert.

I comfirm the send signal when video_time='10' instead video_time = reuqest.POST.get('video_time'), but using ajax, there are no success message. Where is problem?

view

if request.method == 'POST' and request.is_ajax():
        video_view.send(
             request.user,
             video_time=request.POST.get('video_time'),
             primary_obj_video=obj,
             secondary_obj_video=cat
        )

template

wistiaEmbed = jQuery(".wistia_embed")[0].wistiaApi;

var time = wistiaEmbed.duration();

alert(time);

$.ajax({
    type: "POST",
    data: {video_time: time},
    success: function(){
        alert ("hi");
    }
});

Solution

  • url is missing inside ajax():

    $.ajax({
       url: '/your_url/', #<-----------------
       type: "POST",
       data: {video_time: time},
       success: function(){
        alert ("hi");
       }
    });