pet.find - practice

by Cody Dhein

HTML

<h2>
  Sample Request Pulling Dogs 1 - 4 
</h2>
<h3>
  Sample Request URL:
</h3>
<span id="sample-request"></span>
<h3>
  Sample Results:
</h3>
<pre id="sample-results"></pre>
<h2>
Your Request. Pull Dogs 3 and 4 Only
</h2>

<h3>
  Your Request URL:
</h3>
<span id="your-request"></span>
<h3>
  Your Results:
</h3>
<pre id="your-results"></pre>

JavaScript

$(document).ready(function(){
	sampleCall();
	
  /* uncomment when ready to test your call */
  //yourCall();

});



function yourCall(){
	var baseURL = "https://api.petfinder.com/";
  var reqType = "pet.find?";
  var params = "animal=dog&location=53217&output=basic&&"; /* complete me to grab the 2nd and 3rd dogs */
  var yourKey = "key=123456789&";
  var format = "format=json";
  var callback = "&callback=?";
  
  var yourURL = baseURL+reqType+params+yourKey+format+callback;
  $("#your-request").text(yourURL);
  $.ajax({
    dataType: "jsonp",
    url: yourURL,
    success:(function(data){
      var prettyData = JSON.stringify(data, null,'\t');
      $("#your-results").text(prettyData);

    })
  });  
}


/*DO NOT CHANGE */
function sampleCall(){
  var sampleURL = "https://api.petfinder.com/pet.find?animal=dog&key=dcc5be07eeae2e3fed49e529ed8cf73b&location=53217&count=4&output=basic&format=json&callback=?";
  $("#sample-request").text(sampleURL);

  $.ajax({
    dataType: "jsonp",
    url: sampleURL,
    success:(function(data){
      var prettyData = JSON.stringify(data, null,'\t');
      $("#sample-results").text(prettyData);

    })
  });
}