Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jquery怎么用 #3

Open
uniquejava opened this issue Dec 7, 2015 · 0 comments
Open

jquery怎么用 #3

uniquejava opened this issue Dec 7, 2015 · 0 comments

Comments

@uniquejava
Copy link
Owner

jQuery

http://www.jquery.com

Usage

<script type="text/javascript" src="${ctx }/assets/js/jquery-1.11.2.min.js"></script>

$.get

see http://api.jquery.com/jQuery.get/

jQuery.get( url [, data ] [, success ] [, dataType ] )

Example:

$.get("${ctx}/admin/ajaxTimeout", null, function(data) {
    alert(JSON.stringify(data));
}, "json");

$.post

see http://api.jquery.com/jQuery.post/

jQuery.post( url [, data ] [, success ] [, dataType ] )

Example:

$.post("${ctx}/login", {
    user : user,
    pwd : pwd
}, function(data) {
    if (data.code == 200) {
        window.location = '${ctx}/admin';
    } else {
        $error.html("<label>" + data.msg + "</label>");
        $error.show();
    }
}, "json");

$.ajax

see http://api.jquery.com/jQuery.ajax/

jQuery.ajax( [settings ] ) or jQuery.ajax( url [, settings ] )

The settings:

  • async (default: true)
  • type GET,POST,PUT,DELETE
  • data PlainObject or String or Array
  • dataType xml,html,script,json,jsonp,text
  • success
  • timeout
  • error
    *

Example:

// Assign handlers immediately after making the request,
// and remember the jqXHR object for this request
var jqxhr = $.ajax( "example.php" )
    .done(function() {
        alert( "success" );
    })
    .fail(function() {
        alert( "error" );
    })
    .always(function() {
        alert( "complete" );
    });

// Perform other work here ...

// Set another completion function for the request above
jqxhr.always(function() {
    alert( "second complete" );
});

$.getJson()

see http://api.jquery.com/jQuery.getJSON/

jQuery.getJSON( url [, data ] [, success ] )

$.ajax({
  dataType: "json",
  url: url,
  data: data,
  success: success
})

APIs

  1. prepend
  2. append
@uniquejava uniquejava mentioned this issue Jun 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant