Jquery ajax in basic grammar

A. $. Ajax the basic structure used
 var Response = $ .ajax ({
        type: "POST",
        url: "/index.php?m=content&c=index&a=getList",
        data: {
            "page" : currentPage,
            "pTime":new Date().getTime()
        },
        dataType: "json",
        beforeSend: function () {
             // code hints when sending 
        },
        Success: function (Data) {
             // code hints while successful 
        },
        Complete: function () {
             // code hints at the completion 
        },
        error: function (MSG) {
             // code for the given prompt 
        },
        async: true
    });
II. $. The basic structure of the use of post
var data = {
      'page':page,
      'pagesize':pagesize,
      'type': type
    }
    $.post(
        '/index.php?m=content&c=index&a=index',
        data,
        function(data){
            console.log(data);
        },
        'json'
    );
Three. $. Ajax event of onready
$ ( Function () {
      // load event 
});
$ (the Document) .ready ( function () {
   // load event 
});
Four .juery binding method of dynamic elements on the event click on things
/**
 * Event binding process
 * / 
The jQuery (Document) .on ( "the Click", "[the rel = 'zanLink']", function (Event) {
     // determines whether the landing 
    IF (! JQuery.cookie ( "58haha_t" )) {
      window.location.href = passport_login;
      return false;
    }
    // Code Processing 
});

Guess you like

Origin www.cnblogs.com/yeshaoxiang/p/12043714.html