Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • jQuery AJAX load()

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 382
    Comment on it

    It is a very simple and powerful ajax method to load the data from the server and display it in the selected element.


    URL parameter specifies the URL you wish to load

    data parameter specifies a set of querystring key/value pairs to send along with the request.

    callback parameter is the name of a function to be executed after the load() method is completed.



    We can also jQuery selector to the  url parameter.

    $("#div1").load("demo_test.txt #p1");

    callback parameter specifies a callback function to run when the load() method is complete

    1. responseTxt - contains the resulting content if the call succeeds

    2. statusTxt - contains the status of the call

    3. xhr - contains the XMLHttpRequest object

        $("#div1").load("demo_test.txt", function(responseTxt, statusTxt, xhr){
            if(statusTxt == "success")
                alert("External content loaded successfully!");
            if(statusTxt == "error")
                alert("Error: " + xhr.status + ": " + xhr.statusText);


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: