Ajax with Python - I want to call function that is in default

-1

I'm looking to do a validation on the MySQL Bank via Ajax. I created a function called validaCNPJ () which is in the controller called Default .

But I do not know how I put this function in the Ajax parameters. Can anyone give me the path of the stones?

This is my Script that is on the HTML page:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script><script>$(document).ready(function(){$("idCnpj").typehead(function(){
         $.ajax({url: "???????? ", success: function(result){
            $("#div1").html(result);
        }});
    });
});
</script>
    
asked by anonymous 06.06.2016 / 14:41

1 answer

0

It's not clear what web framework you use but come on:

According to the jQuery API documentation , you can set the method attribute to POST will POST in some view of you prepared to receive these data and treat them.

$.ajax({
  method: "POST",
  url: "some.php",
  data: { name: "John", location: "Boston" }
})
  .done(function( msg ) {
    alert( "Data Saved: " + msg );
  });

In addition to method , we have the url which is where POST should be done and the data attribute containing the data of your form.

The done function is the callback of AJAX on success.

If it is not clear, I suggest you study this W3Schools link.

    
11.11.2016 / 13:49