Reputation: 659
$('#rn_s').keyup(function() {
var rn = $('#rn_s').val();
if(rn.length == 9) {
$.ajax({
url: 'http://routingnumbers.info/api/data.json?rn=' + rn,
type: 'GET',
dataType: 'jsonp',
success: function(result) {
console.log(result);
}
});
}
});
And it returns this:
Resource interpreted as Script but transferred with MIME type text/plain
And then returned content is Object {}
How can I access these values?
Upvotes: 0
Views: 457
Reputation: 532
Seems to be working okay for me. I created a fiddle, using chrome and the latest version of jQuery (not v2).
This is basically what you had, minus the keyUp events:
var rn = 122242597;
$.ajax({
url: 'http://routingnumbers.info/api/data.json?rn=' + rn,
type: 'GET',
dataType: 'jsonp',
success: function (result) {
console.log(result);
$('#customerName').text(result.customer_name);
$('#address').text(result.address);
$('#zipCode').text(result.zip);
} });
Then in your HTML:
<div>
<span id="customerName"></span>
</div>
<div>
<span id="address"></span>
</div>
<div>
<span id="zipCode"></span>
</div>
Check this fiddle for a working example. Obviously your HTML will differ, but accessing the returned properties and assigning them to your UI should be similar.
Upvotes: 1
Reputation: 2588
Have you looked at that API's documentation? That call returns a json
object.
http://www.routingnumbers.info/api/data.html
To access the values, look at the API documentation for the value names. For example, to get the address of the result:
var address = result.address
Upvotes: 0