JSONP Mac address vendor lookup

JSONP Mac address vendor lookup



Another small chunk of code to show you how to use our Mac address vendor Lookup API in JSONP with jQuery.

<html>
<head>
<title>Macvendors.co JSONP API Example</title>
</head>
<body>
<div style="width:700px;margin:0 auto;">
<h2><a href="https://macvendors.co">Macvendors.co</a> JSONP API Example</h2>
<label>Enter mac address:</label>
<input type="text" id="mac_address" />
<input type="button" value="Lookup!" onclick="lookup();" />
<div id="result" style="margin-top:10px;"></div>
</div>
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script>
function lookup (){
var mac_address= $('#mac_address').val();
if(mac_address.length < 6){
alert("Please enter at least 6 chars!");
return;
}
$.ajax({
type: 'GET',
url: 'http://macvendors.co/api/jsonp/'+mac_address,
dataType: 'jsonp',
crossDomain: true,
}).done(function(response){
if(response.result.error){
$('#result').html(response.result.error);
}else{
$('#result').html("Company Name:"+response.result.company+"<br/>");
$('#result').append("Address: "+response.result.address+"<br/>");
$('#result').append("Mac Prefix: "+response.result.mac_prefix);
}
}).fail(function(error){
alert(error.statusText);
});
}
</script>
</body>
</html>
view raw Macvendors.html hosted with ❤ by GitHub
You can use this link if you need to do JSONP call with any other framework
http://macvendors.co/jsonp/{QUERY}?callback=myfunc
And replace {QUERY} with your string and myfunc with your callback function.

Have an issue or question ?

As you can see it's straight forward example
However. if you needed any help please use Contact us form.