I'm trying to consume an api through Ajax, but I get an error executing 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
How should it be:
https://demo.ckan.org/api/3/action/datastore_search?resource_id=1d7e45e5-b159-46a2-bdce-90393c7a8a2b&limit=5&q=jones