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 Faire Mii <fa...@gmail.com> on 2009/12/14 12:26:02 UTC

why cant i send to solr using jquery post/get function?

when i enter http://localhost:8983/solr/select/?q=body:hello in the  
URL field i get all the results.

but when i'm using jquery code:

$.post('http://localhost:8983/solr/select/?q=body:hello, function(data){
         alert(data);
});


OR

$.post('http://localhost:8983/solr/select/?, {q: 'body:hello'},  
function(data){
         alert(data);
});


i get nothing. it doesnt give me anything. it doesnt even give me an  
alert.

i have tried $.get as well without result.

what could the problem be?



Regards

Fayer


Re: why cant i send to solr using jquery post/get function?

Posted by Faire Mii <fa...@gmail.com>.
firebug shows no response. i have tried to use "index.php" instead of  
the solr url and then it works and i get an alert. but when i enter:

>> http://localhost:8983/solr/select/?q=body:hello

as the url it doesnt work and nothing shows in firebug.

i dont think it communicates with the solr. is there something i have  
to configure in solr to make sending through jquery working?


On Dec 14, 2009, at 12:52 PM, khalid y wrote:

> In your place, I prefer to set the return format type in jquery like  
> this
> example :
>
> $.post("test.php", { func: "getNameAndTime" },
>  function(data){
>    alert(data.name); // John
>    console.log(data.time); //  2pm
>  }, "json");
>
> and in the server side with wt parameter wt=json
>
>
> So
>
> $.post("http://localhost:8983/solr/select/?q=body:hello&wt=json",
>  function(data){
>    alert(data.name); // John
>    console.log(data.time); //  2pm
>  }, "json");
>
> And I'm not sure that the best way to query solr is POST. Get is  
> recommanded.
>
> $.get("http://localhost:8983/solr/select/?q=body:hello&wt=json",  
> function(data){
>  alert("Data Loaded: " + data);
> }, "json" );
>
>
>
>
> 2009/12/14 Faire Mii <fa...@gmail.com>
>
>> when i enter http://localhost:8983/solr/select/?q=body:hello in the  
>> URL
>> field i get all the results.
>>
>> but when i'm using jquery code:
>>
>> $.post('http://localhost:8983/solr/select/?q=body:hello, function 
>> (data){
>>       alert(data);
>> });
>>
>>
>> OR
>>
>> $.post('http://localhost:8983/solr/select/?, {q: 'body:hello'},
>> function(data){
>>       alert(data);
>> });
>>
>>
>> i get nothing. it doesnt give me anything. it doesnt even give me  
>> an alert.
>>
>> i have tried $.get as well without result.
>>
>> what could the problem be?
>>
>>
>>
>> Regards
>>
>> Fayer
>>
>>


Re: why cant i send to solr using jquery post/get function?

Posted by khalid y <ke...@gmail.com>.
In your place, I prefer to set the return format type in jquery like this
example :

$.post("test.php", { func: "getNameAndTime" },
  function(data){
    alert(data.name); // John
    console.log(data.time); //  2pm
  }, "json");

and in the server side with wt parameter wt=json


So

$.post("http://localhost:8983/solr/select/?q=body:hello&wt=json",
  function(data){
    alert(data.name); // John
    console.log(data.time); //  2pm
  }, "json");

And I'm not sure that the best way to query solr is POST. Get is recommanded.

$.get("http://localhost:8983/solr/select/?q=body:hello&wt=json", function(data){
  alert("Data Loaded: " + data);
}, "json" );




2009/12/14 Faire Mii <fa...@gmail.com>

> when i enter http://localhost:8983/solr/select/?q=body:hello in the URL
> field i get all the results.
>
> but when i'm using jquery code:
>
> $.post('http://localhost:8983/solr/select/?q=body:hello, function(data){
>        alert(data);
> });
>
>
> OR
>
> $.post('http://localhost:8983/solr/select/?, {q: 'body:hello'},
> function(data){
>        alert(data);
> });
>
>
> i get nothing. it doesnt give me anything. it doesnt even give me an alert.
>
> i have tried $.get as well without result.
>
> what could the problem be?
>
>
>
> Regards
>
> Fayer
>
>

Re: why cant i send to solr using jquery post/get function?

Posted by Faire Mii <fa...@gmail.com>.
yes i tried this:


>> $.post('http://localhost:8983/solr/select/?q=body:hello&wt=json,  
>> function(data){
>>       alert(data);
>> });


but it doesnt work.

could someone try that code in your app to see if it works. or is  
there another way of accessing through jquery?


On Dec 14, 2009, at 12:46 PM, khalid y wrote:

> Are you tried with params wt="json" ?
>
> 2009/12/14 Faire Mii <fa...@gmail.com>
>
>> when i enter http://localhost:8983/solr/select/?q=body:hello in the  
>> URL
>> field i get all the results.
>>
>> but when i'm using jquery code:
>>
>> $.post('http://localhost:8983/solr/select/?q=body:hello, function 
>> (data){
>>       alert(data);
>> });
>>
>>
>> OR
>>
>> $.post('http://localhost:8983/solr/select/?, {q: 'body:hello'},
>> function(data){
>>       alert(data);
>> });
>>
>>
>> i get nothing. it doesnt give me anything. it doesnt even give me  
>> an alert.
>>
>> i have tried $.get as well without result.
>>
>> what could the problem be?
>>
>>
>>
>> Regards
>>
>> Fayer
>>
>>


Re: why cant i send to solr using jquery post/get function?

Posted by khalid y <ke...@gmail.com>.
Are you tried with params wt="json" ?

2009/12/14 Faire Mii <fa...@gmail.com>

> when i enter http://localhost:8983/solr/select/?q=body:hello in the URL
> field i get all the results.
>
> but when i'm using jquery code:
>
> $.post('http://localhost:8983/solr/select/?q=body:hello, function(data){
>        alert(data);
> });
>
>
> OR
>
> $.post('http://localhost:8983/solr/select/?, {q: 'body:hello'},
> function(data){
>        alert(data);
> });
>
>
> i get nothing. it doesnt give me anything. it doesnt even give me an alert.
>
> i have tried $.get as well without result.
>
> what could the problem be?
>
>
>
> Regards
>
> Fayer
>
>