views:

43

answers:

2

My friend has a search engine that he wants to have a widget access that can be put on other web pages. If I send a request to the search engine, it returns an XML file. The request would look something like this: http://www.site.com/page.php?keyword=this+is+a+sample&page=1&num_days=3&source_id=site2.com&source_name=site2&source_url=sampleurl.php

I understand how to access this by using Javascript. However, I know that you can't do a cross-domain request. I would have to have it load a new page at the search engines's site and not in the window at the the site they were located at....right? Any ideas or insight are greatly appreciated.

+2  A: 

JSONP to the rescue. Check this article

Vinko Vrsalovic
+4  A: 

Here is a good explanation too:

http://stackoverflow.com/questions/2067472/please-explain-jsonp

EDIT:

jsonpString

Override the callback function name in a jsonp request. This value will be used instead of callback in the callback=? part of the query string in the url. So {jsonp:'onJsonPLoad'} would result in 'onJsonPLoad=?' passed to the server.

 

jsonpCallbackString

Specify the callback function name for a jsonp request. This value will be used instead of the random name automatically generated by jQuery. It is preferable to let jQuery generate a unique name as it'll make it easier to manage the requests and provide callbacks and error handling. You may want to specify the callback when you want to enable better browser caching of GET requests.

taken from: http://api.jquery.com/jQuery.ajax/

KakambaWeb
If using this method, would I be able to use jQuery instead? I am assuming not since it is still going cross-browser.
patricksweeney
sure you can. see EDIT part.
KakambaWeb