You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Romi <ro...@gmail.com> on 2011/06/22 08:21:00 UTC
Problem in accessing a variable's changed value outside of if block
in javascript code
*$("#submit").click(function(){
var query=getquerystring() ; //get the query string entered by user
// get the JSON response from solr server
var newquery=query;
$.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+query+"&json.wrf=?",
function(result){
//$.each(result.response.docs, function(result){
if(result.response.numFound==0)
{
$.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+query+"&spellcheck=true&json.wrf=?",
function(result){
$.each(result.spellcheck.suggestions, function(i,item){
newquery=item.suggestion;
});
});
}*
favorite
$("#submit").click(function(){
var query=getquerystring() ; //get the query string entered by user
// get the JSON response from solr server
var newquery=query;
$.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+query+"&json.wrf=?",
function(result){
//$.each(result.response.docs, function(result){
if(result.response.numFound==0)
{
$.getJSON("http://192.168.1.9:8983/solr/db/select/?wt=json&&start=0&rows=100&q="+query+"&spellcheck=true&json.wrf=?",
function(result){
$.each(result.spellcheck.suggestions, function(i,item){
newquery=item.suggestion;
});
});
}
In the above javascript code a variable newquery initialy having value of
query. but when the if condition is true its value have changed. but my
problem is i am not getting its changed value outside of if block while i
want this changed value. how can i do this.
-----
Thanks & Regards
Romi
--
View this message in context: http://lucene.472066.n3.nabble.com/Problem-in-accessing-a-variable-s-changed-value-outside-of-if-block-in-javascript-code-tp3094342p3094342.html
Sent from the Solr - User mailing list archive at Nabble.com.