0

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

displays the syntax and available parameters of getJSON() as:

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

I am learning how to use this method and all the tutorials I have come across use:

jQuery.getJSON( "http://path/to/file.php", function(my_results) {

// do something with the my_results variable

}

I have got this working, but, in my newbie mind, such an example veers off from the available parameters pretty early, the only consistency that I can see being the URL parameter. And a function() is added however it is not shown in the 'available parameters' example.

Could anyone provide an example of a getJSON() method implementation where all the available parameters are used, with annotation about what each parameter is doing?

2 Answers 2

2

Is it enough or you need more details?

$.getJSON({
  url: '/file.php',
  data: {value1:"1",value2:"2"},
  success: function(data){ console.log(data);}
});
Sign up to request clarification or add additional context in comments.

2 Comments

What is data: {value1:"1",value2:"2"} representing? Are those pairs that are being searched for in file.php and therefore they are the only pairs being returned? Or something else?
the values there are value-pair you will get on server value1 equal 1, they will send as get on php so you can do on server $_GET['value1'] and it will equals 1, makrk the question as resolved if it helped you
0

try this example to read RSS/ATOM feed from Google Feed Proxy http://jsfiddle.net/ck4Ct/

// Data object: RSS feed URL, number of entries to return, result format, API version
var data = {
    q: 'http://feeds.bbci.co.uk/news/video_and_audio/news_front_page/rss.xml'
    , num: 10
    , output: 'json'
    , v: '1.0'
};

// AJAX call to Google Feed API which converts ATOM/RSS feed to JSON
// Callback param added to url to do JSONP request
$.getJSON('http://ajax.googleapis.com/ajax/services/feed/load?callback=?'
            , data 
            , function (json) {
                alert(json.responseData.feed.entries[0].title)
            }
);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.