javascript - post something in django without refreshing (JQuery, AJAX ?) -


i coding music quiz in django + html + javascript , stucked.

what want count time player made find solution. have not synchronized because of loading time of music. idea send django when player started , store time.time() in django @ moment (without refreshing page !). after that, when player click on song thought is, posts form, compare new time.time() previous 1 , over.

everything works don't know lot jquery , ajax , think way post without refreshing page.

my javascript (this timer here nice see don't want post time calculated on javascript, because, post time wants !) :

function onplayerstatechange(event) {     if (event.data == yt.playerstate.playing){         //post start django         settimeout(function decompte() {              settimeout(function() {                 te--;                 if (te<0) {                     te = 9; sc--                 }                 time = sc+" s "+te;                 form.time.value=time;                 if (end) {                     return;                 }                 else if (sc == 0 & te == 0) {                     zero()                 }                 decompte();             }, 100);         },0); //launch function... not esthetic way works !     } } 

any ideas ?

it can done simple jquery post request. there lots of example given in following sample django project. has proper html/jquery send ajax call , urls.py receive , myapp/views.py process , return response.

https://github.com/sivaa/django-jquery-ajax-exmaples


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -