Created
November 2, 2011 02:41
-
-
Save jdjkelly/1332714 to your computer and use it in GitHub Desktop.
Bing Spelling in JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AppId = "D8E9ED76519B0D51D42D53256188D00E3A7BB2C2"; | |
var requestStr = "http://api.bing.net/json.aspx?" | |
// Common request fields (required) | |
+ "AppId=" + AppId | |
+ "&Query=<?php the_search_query();?>" | |
+ "&Sources=Spell" | |
// Common request fields (optional) | |
+ "&Version=2.0" | |
+ "&Market=en-us" | |
+ "&Options=EnableHighlighting" | |
// JSON-specific request fields (optional) | |
+ "&JsonType=callback" | |
+ "&JsonCallback=?"; | |
$(document).ready(function () { | |
$.getJSON(requestStr, function (data) { | |
console.log(data); | |
var spellingResponse = data.SearchResponse.Spell.Results[0].Value; | |
$('.category h3').append(' <span class="search-results">Did you mean <a href="http://varsity.kmsm.ca/?s=' + spellingResponse + '">' + spellingResponse + '</a>?</span>'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment