0
I’m trying to consume an api through Ajax, but I get error while running it.
var data2 = {
resource_id: '1d7e45e5-b159-46a2-bdce-90393c7a8a2b', // the resource id
limit: 5, // get 5 results
q: 'jones', // query for 'jones'
};
$.ajax({
url: 'https://demo.ckan.org/api/3/action/datastore_search',
data: data2,
dataType: 'jsonp',
success: function (data2)
{
debugger;
alert('Total results found: ' + data2.result.total)
}
});
In the Browser Console I noticed that it adds two parameters that I did not pass :callback=jQuery21409543886738626624_1528899809074 e &_=1528899809075
URL that appears in the console:
https://demo.ckan.org/api/3/action/datastore_search?callback=jQuery21409543886738626624_1528899809074&resource_id=1d7e45e5-b159-46a2-bdce-90393c7a8a2b&limit=5&q=jones&_=1528899809075
As it should be:
https://demo.ckan.org/api/3/action/datastore_search?resource_id=1d7e45e5-b159-46a2-bdce-90393c7a8a2b&limit=5&q=jones
You solved my problem. Thank you very much !
– Vini LoTrek
Thank you. If possible vote as an answer. Att.
– Netinho Santos