Senin, 27 April 2020

AJAX in JQuery

Again, it is just a quick post that helps me recall something that I forget easily. Here is the syntax for AJAX in JQuery. I have seen 2 types of AJAX syntax in JQuery, for me this syntax is much easier to understand.


$.ajax({
            type:"POST",
            url:"urlToAjax.php",
            data:{
              "data1":dat,
              "data2":dat2 
            },
            success : function(results) {
              console.log(results)
              //any code if succeed goes here 
            },
            error : function(res){
              console.log(res)
              //any code to generate error report goes here
            }
  });


The code above sends Request using POST.

That's all folks.

Tidak ada komentar:

Posting Komentar