Closed matthias-samwald closed 10 years ago
doing a cross-domain ajax requests with $.getJSON returns: ReferenceError: NSuggest_CreateData is not defined http://preview.ncbi.nlm.nih.gov/portal/utils/autocomp.fcgi?dict=pm_related_queries_2&callback=jQuery19107535881639678947_1410267864034&q=diabet&_=1410267864035 because "As of jQuery 1.4, if the JSON file contains a syntax error, the request will usually fail silently."
doing a cross-domain ajax request with $.get returns: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://preview.ncbi.nlm.nih.gov/portal/utils/autocomp.fcgi?dict=pm_related_queries_2&callback=?&q=diabet. This can be fixed by moving the resource to the same domain or enabling CORS. http://preview.ncbi.nlm.nih.gov/portal/utils/autocomp.fcgi?dict=pm_related_queries_2&callback=?&q=diabet
what I don't get, why https://gist.github.com/gpetz/55050eaac9f5e183acd4 is working
Well I guess the error is still caused by the cliend-side, not the remote PubMed server, right?
@ReferenceError: As the NCBI API doesn't return valid JSON, we can't do JSONP. (The same-origin policy prevents access to DOM on different sites!) The do that to stop anyone outside ncbi.nlm.nih.gov from accessing the data.
@Cross-Origin Request Blocked: Using a CORS proxy somehow works
@Gist Code: The 'return false;' (https://gist.github.com/gpetz/55050eaac9f5e183acd4#file-pubmed-L13) is somehow important.
"Working hack" sounds good enough for the time being, right?
successfully tested it on mobile versions of Safari, Firefox and Chrome:
(fixed checkbox size issue in 3984e479a74b1140453e270bde1f9109f39689dc)
The current solution is too sluggish, also it might eventually get the FindMeEvidence server banned from the NCBI API because of too many requests.
Re-implement as direct AJAX calls from the browser to the PubMed API.