i have implemented search in my E commerce application. which hit solr(running on port 8983) 开发者_JS百科to get the search result
solr url is
url =solrURL+"/solr/db/select/?qt=dismax&wt=json&&start="+start+"&rows="+end+"&q="+lowerCaseQuery+"&hl=true&hl.fl=text&hl.usePhraseHighlighter=true&sort= score desc ,"+sort+" "+order+"&json.wrf=?"
and using getJson i am getting the solr response.
$.getJSON(url, function(result){
now my problem is how can i determine that solr server is running.
EDIT:
$
.ajax({
url: "http://192.168.1.9:8983/solr/db/admin/ping",
success:function(){
alert("ok");
},
error: function()
{
alert("dsd");
}
})
You need to specify a timeout value. Though getJSON
does not specify one you may use the jquery method $.ajax
see: http://api.jquery.com/jQuery.ajax/
$.ajax({
url: url,
dataType: 'json',
data: data,
success: callback,
timeout: 3000 //3 second timeout
});
For the ping you may check the following snippet:
$.ajax({
url: 'http://192.168.1.9:8983/solr/db/admin/ping',
type: 'GET',
complete: function(transport) {
if(transport.status == 200) {
alert('Success');
} else {
alert('Failed');
}
}
});
精彩评论