I’m using Bing Search API (Azure) to retrieve a list of newsheadlines using javascript/json. It’s working but for some reason ignoring the $top (count) value, and giving me the default/maximum (15) number of results regardless of what I put there.
The call is:
https://api.datamarket.azure.com/Data.ashx/Bing/Search/Composite?$format=JSON&Query=%27MyQuery%27&Sources=%27news%27&Market=%27en-US%27&Adult=%27Off%27&$top=5&$skip=0
I could limit it using the code on my page, but that seems wasteful to me. I have a suspicion that it’s something obvious that I’m missing..
Your help is appreciated.
Note: the actual line of code within $.ajax that i’m using is a proxy php script:
url: "scripts/bingapi.php?query=" + escape("https://api.datamarket.azure.com/Data.ashx/Bing/Search/Composite?$format=JSON&Query=%27MyQuery%27&Sources=%27news%27&Market=%27en-US%27&Adult=%27Off%27&$top=10&$skip=0"),
Could it be something related to ‘escape’?
The issue you are experiencing is due to JavaScript’s escape not handling the dollar sign
$character. I would suggest using encodeURIComponent instead like so:I hope this helps!