jquery - JavaScript get JSON from rest API without re-rendering the page -


problem

i'm trying query rest api in javascript , use jquery parse , insert results webpage. when query made believe submits search form , re-renders page removing of elements queried , inserted.

is there away json object rest api , not re-render webpage?

here's i'm using make requests:

function get_data(){     var url = "www.rest_api/search_term&apikey=my_key"     var xmlhttp = null;     xmlhttp = new xmlhttprequest();     xmlhttp.open( "get", url, false );     xmlhttp.send( null );     return xmlhttp.responsetext; } 

the search term comes simple input form, , submitted when submit button clicked. goal keep webpage single page , avoid results page.

what i've tried

i can't return json object

get json data external url , display in div plain text

http://api.jquery.com/jquery.getjson/

request url example:

http://woof.magnify.net/api/content/find?vq=karma&per_page=5&page=1&sort=popularity&key=84lthnzq1364w14d&format=json

remember when calling jsonp apis, have add additional parameter url : callback=?

here's simple fiddle example: http://jsfiddle.net/8dxxn/


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -