简体   繁体   中英

Django POST method using Jquery

Im trying to do a POST request using JQuery but my JQuery scripts fails when I add the .ajax call.

When I remove the ajax calls the alert method is displayed without any problems.

Question:

What would be the syntax error or possible other errors?

$("#table_appl,#table_enfr,#table_det01,#table_det02,#table_det03,#table_det04,#table_det05,#table_datais").on( "click", "input:submit", function( event ) {
            alert('Hi')
            //event.preventDefault();

              $.ajax({

                    type:"POST",

                    url:"/validate/"

                    success:function(data){
                        alert(data);
                    }

               });

            return false;

        })

A few things I would change:

1. Change:

"input:submit"

to:

'input[type="submit"]'

2. Change:

url:"/validate/"

to:

url:"/validate/",

3. Specify data in your $.ajax call.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM