我有一个我无法解决的问题。部分是因为我不能用正确的条件来解释。我对这个问题感到很抱歉。
下面你可以看到我的目标概述。
我正在使用Magento 1.7.0.2 & Solr 4.6.0。
var url1 ="http://127.0.0.1:8080/solr/select?q=iphon&wt=json&json.wrf=?";
$.getJSON(url1,function(result){
// my logic
});当Server运行时,意味着此脚本正在运行,如果我的Server没有运行,则意味着它无法工作。
但我的目标是这样写剧本..。
if( Solr Server is Running){
var url1 ="http://127.0.0.1:8080/solr/select?q=iphon&wt=json&json.wrf=?";
$.getJSON(url1,function(result){
// my logic-1
});
}else{
// my logic-2
}那么,我如何知道Solr服务器是否正在运行呢?
&我知道这是一个重复的问题,但我从来没有找到解决办法,所以请忽略它。
有什么想法吗?
发布于 2014-03-21 06:23:02
<?php
$solr = new Apache_Solr_Service( 'HOST', 'PORT NUM', '/solr' );
if ( $solr->ping() ) {
// APACHE SOLR SERVER IS RUNNING
}else{
// APACHE SOLR SERVER IS NOT RUNNING
}
?>我希望它能用满的来做一个。
发布于 2014-03-10 07:01:20
不知道SOLR是如何工作的,但正确的jQuery应该是:
$.ajax({
type: "GET",
url: "http://127.0.0.1:8080/solr/select?q=iphon&wt=json&json.wrf=?",
dataType: "json",
success: function (result) {
// is working
},
error: function (result) {
// probably not
}
});发布于 2014-03-11 05:34:03
在尝试连接之前使用setTimeout。如果您成功使用clearTimeout。如果您没有在setTimeout时间内,您可以执行您定义的setTimeout所要做的事情。
https://stackoverflow.com/questions/22293498
复制相似问题