Programming:Snippets

From Amar
Revision as of 11:20, 9 June 2022 by Lax (talk | contribs) (Created page with "= JQuery = == AJAX == let request = $.ajax({ url: "/ajax/'''<call>'''", method: "POST", data: { 'fld' : '''fld''', 'fld2' : '''...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

JQuery

AJAX

 let request = $.ajax({
       url: "/ajax/<call>",
       method: "POST",
       data: {
           'fld'  : fld,
   	    'fld2' : fld2
       },
       dataType: "json"
   });

   request.done(function( msg ) {
       // redraw page
       // alert(JSON.stringify(msg,null,3));
       $('#message').html(
           // 'DEBUG '+ msg['DEBUG']
           // + 'msg '+JSON.stringify(msg,null,3)
       );
       fld  = msg['fld'];
       fld2 = msg['fld2'];
       display(msg);
   });

   request.fail(function( jqXHR, textStatus ) {
       alert( "Request failed: " + textStatus );
   });