How to update database with jQuery without refreshing the page?

前端 未结 2 1002
北海茫月
北海茫月 2021-01-28 02:38

How do I send this display_false() function to the server with jQuery so that the database is updated without refreshing the page?

    def display_f         


        
相关标签:
2条回答
  • 2021-01-28 03:31

    You'll need an AJAX call, something like this after including your jQuery libraries.

    $(document).ready(function() {
    
    //false click action
    $("a.false").click(function () { 
    
    //ajax server call
    $.ajax({
      url: '/useradminpage?main_id=%s&display=false',
      success: function(data) {
        //do some stuff.
        alert('returned');
      }
    });
    
    });
    
    
    
    });
    
    0 讨论(0)
  • 2021-01-28 03:34

    You cannot update a server database with JQuery. All you can do is send a request that is handled by the server.

    Use JQuery.Ajax or any spin-offs of that function to send the request. To your server it will look as a regular request.

    0 讨论(0)
提交回复
热议问题