Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to make a JSON call using jQuery?

    • 0
    • 4
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 109
    Comment on it

    To make JSON call we use getJSON method. Here is the syntax and description of it.

    Syntax :

    $.getJSON( url, [data], [callback] )


    1. url : It is URL where the request is send and which emits out JSON.

    2. data : this parameter helps us to pass data to the server.

    3. callback : this parameter is a function which gets invoked when data is returned and the data gets loaded successfully.

    Below is the small example of using it:

    I am assuming that the response.json file contains the following content -

    emp-name": ABCD,
    emp-age" : "67",
    emp-code: 4567

    Now below code is the example that shows the usage of this method-

          <script type="text/javascript" src=""></script>
          <script type="text/javascript" language="javascript">
             $(document).ready(function() {
                   $.getJSON('response.json', function(data) {
                      $(#eg1).html('<p>Name: ' + + '</p>');
                      $('#eg1).append('<p>Age : ' + data.age+ '</p>');
                      $('#eg1').append('<p>Code : ' + data.code+ '</p>');
          <p>Click the button:</p>
          <div id=eg1 style="background-color:#dddd;>
          <input type="button" id=demo value=Show Data" />

    This is how you can simply make a JSON call using jquery.

 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: