pyramid - dynamicly fill table using zpt and ajax as update -


i'm creating webproject in pyramid i'd update table every few secondes. decided use ajax, i'm stuck on something.

on client side i'm using following code:

    function update()     {     var variable = 'variable ';     $.ajax({         type: "post",         url: "/diagnose_voorstel_get_data/${dosierid}",         datatype: "text",         data: variable ,         success: function (msg) {         alert(json.stringify(msg));                    },         error: function(){             alert(msg + 'error');           }                               });     } 

pyramid side:

@view_config(route_name='diagnose_voorstel_get_data', xhr=true, renderer='string')     def diagnose_voorstel_get_data(request):     dosierid = request.matchdict['dosierid']     dosieridsplit = dosierid.split          diagnoses = dbsession.query(diagnose).filter(and_(diagnose.code_arg == str(dosieridsplit[0]), diagnose.year_registr == str(dosieridsplit[1]), diagnose.period_registr == str(dosieridsplit[2]), diagnose.staynum == str(dosieridsplit[3]), diagnose.order_spec == str(dosieridsplit[4])))            return {'diagnoses ' : diagnoses } 

now want put data inside table zpt using tal:repeat statement. know how use put data in table when page loads, don't know how combine ajax.

can anny1 me problem ? in adance.

you can ajax, mean "there's no possibility"? things become cleaner once see runs , in order - martijn pieters points out, there's no zpt in browser , there's no ajax on server, title of question not make sense.

some of options are:

  • clent sends ajax request, server server-side stuff, in ajax call success handler client reloads whole page using window.location.search='ts=' + some_timestamp_to_invalidate_cache. whole page reload new data - although works normal form submit, not sense using ajax @ all.

  • client sends ajax request, server returns html fragment rendered zpt client appends element on page in ajax success handler:

    function update() {     var variable = 'variable ';     $.post("/diagnose_voorstel_get_data/${dosierid}")        .done(function (data) {'            $('#mytable tbody').append(data);       }); } 
  • client sends ajax request, server returns json object render on client using 1 of client-side templating engines. make sense if render whole application on client , server provides data json.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -