{"id":5478,"date":"2017-10-10T02:30:10","date_gmt":"2017-10-10T02:30:10","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=5478"},"modified":"2017-10-10T02:30:10","modified_gmt":"2017-10-10T02:30:10","slug":"fixing-error-talking-solr-unexpected-token-jsonp","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/fixing-error-talking-solr-unexpected-token-jsonp\/","title":{"rendered":"Fixing error talking to Solr: &#8220;Unexpected token :&#8221; over JSONP"},"content":{"rendered":"<p>If you try to access solr with JSONP, you can get this error:  &#8220;Fixing error talking to Solr: &#8220;Unexpected token :&#8221; over JSONP&#8221;.<\/p>\n<p>The issue is that the Content-Type header is text\/plain, rather than application\/json.<\/p>\n<p>The solution is to go into your solrconfig.json. comment out the section in queryResponseWriter, so it looks like this:<\/p>\n<p>You also need to make sure these parameters are on the URL: wt=json&#038;json.wrf=callback.<\/p>\n<pre>\n  &lt;queryResponseWriter name=\"json\" class=\"solr.JSONResponseWriter\">\n    &lt;!-- &lt;str name=\"content-type\">text\/plain; charset=UTF-8&lt;\/str> -->\n  &lt;\/queryResponseWriter>\n\n<\/pre>\n<p>For the record, here is the error I got\/:<\/p>\n<pre>\nUncaught SyntaxError: Unexpected token :\nVM1777:1 XHR finished loading: GET \"http:\/\/localhost:3000\/sockjs-node\/info?t=1507602202275\".\n(anonymous) @ VM1777:1\n.\/node_modules\/sockjs-client\/lib\/transport\/browser\/abstract-xhr.js.AbstractXHRObject._start @ abstract-xhr.js:132\n(anonymous) @ abstract-xhr.js:21\nsetTimeout (async)\nAbstractXHRObject @ abstract-xhr.js:20\nXHRLocalObject @ xhr-local.js:8\nInfoAjax @ info-ajax.js:19\n.\/node_modules\/sockjs-client\/lib\/info-receiver.js.InfoReceiver._getReceiver @ info-receiver.js:36\n.\/node_modules\/sockjs-client\/lib\/info-receiver.js.InfoReceiver.doXhr @ info-receiver.js:56\n(anonymous) @ info-receiver.js:25\nsetTimeout (async)\nInfoReceiver @ info-receiver.js:24\nSockJS @ main.js:121\n.\/node_modules\/react-dev-utils\/webpackHotDevClient.js @ webpackHotDevClient.js:47\n__webpack_require__ @ bootstrap a5da7f792035a34edb8e:669\nfn @ bootstrap a5da7f792035a34edb8e:87\n0 @ registerServiceWorker.ts:114\n__webpack_require__ @ bootstrap a5da7f792035a34edb8e:669\n(anonymous) @ bootstrap a5da7f792035a34edb8e:715\n(anonymous) @ bundle.js:719\nfetch-jsonp.js:85 Uncaught (in promise) Error: JSONP request to http:\/\/40.87.64.225:8983\/solr\/talks\/get?id=76460 timed out\n    at fetch-jsonp.js:85\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Fixing error talking to Solr: &#8220;Unexpected token :&#8221; over JSONP<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9],"tags":[517],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/5478"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=5478"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/5478\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=5478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=5478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=5478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}