Trouble querying Solr from JavaScript and displaying results, getting nothing

I am trying to work off of tutorial. I have put my url for solr in the code, copied from solr admin query result to make sure the query should return something.

I try typing in "title:Asian" into text box (that field/search term combo returned results in the admin console query) but when the button is hit, textbox just clears and nothing in output spot.

I used the dev tools from [F12] key of browser to check console and see there was no errors given there, such as for syntax, so not due to that.

Perhaps I am understanding how the url for query works or should be here? If I leave out local host part as shown I just get error for not specifying local full path.

Does anyone see anything wrong here, or have any ideas/tips of what more to do to try and solve the issue?


<title>Solr Ajax Example</title>
<meta charset="UTF-8">
<script language="Javascript">
// derived from
function xmlhttpPost(strURL)
var xmlHttpReq = false;
var self = this;

if (window.XMLHttpRequest) { // Mozilla/Safari
self.xmlHttpReq = new XMLHttpRequest();
else if (window.ActiveXObject) { // IE
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}'POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {

var params = getstandardargs().concat(getquerystring());
var strData = params.join('&');
//document.getElementById("raw").innerHTML = strData;
return false;

function getstandardargs() {
var params = [
, 'indent=on'
, 'hl=true'

return params;
function getquerystring() {
var form = document.forms['f1'];
var query = form.query.value;
qstr = 'q=' + escape(query);
return qstr;

// this function does all the work of parsing the solr response and updating the page.
function updatepage(str)
document.getElementById("raw").innerHTML = str;
var rsp = eval("("+str+")"); // use eval to parse Solr's JSON response
var html = "<br>numFound=" + rsp.response.numFound;
var first =[0];
html += "<br>product name=" +;
var hl = rsp.highlighting[];
if ( != null) { html += "<br>name highlighted: " +[0]; }
if (hl.features != null) { html += "<br>features highligted: " + hl.features[0]; }
document.getElementById("result").innerHTML = html;


<form name="f1" onsubmit='xmlhttpPost("http://localhost:8983/solr/myCore/select?")'>
<p>query: <input name="query" type="text">
<input value="Go" type="submit"></p>

<div id="result"></div>
<p/><pre>Raw JSON String/output: <div id="raw"></div></pre>


No answers yet