incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: jquery and trailing \n
Date Thu, 18 Jun 2009 14:08:47 GMT

On 18 Jun 2009, at 15:51, francisco treacy wrote:

> Awesome, I wasn't aware of these! I'm having fun with Futon :)
>
> $.couch.db('test').allDocs(); for instance works fine.
>
> However from my html page it doesn't... I have the infamous problem of
> trying to make an ajax request to another host (uncaught exception:
> Access to restricted URI denied (NS_ERROR_DOM_BAD_URI)).
>
> I could of course include my html as an attachment and then would have
> it solved - but it would be definitely impractical (I'm developing in/
> editing that page).

Have a look at CouchApp: http://github.com/couchapp/couchapp/tree/master


> Any suggestions? Is there a workaround for this jQuery client from
> request not originated at localhost:5984?

You shouldn't do that :) alternatively you can use Apache's mod_proxy
or similar to proxy CouchDB to your site's domain.

Cheers
Jan
--


>
> Thanks!
>
> Francisco
>
> 2009/6/18 Martin Hilbig <blueonyx@gmx.net>:
>> Hi,
>>
>> maybe you want to check out the nice jquery.couch.js at
>>
>> http://localhost:5984/_utils/script/jquery.couch.js ?
>>
>> have fun
>> martin
>>
>> francisco treacy wrote:
>>>
>>> Thanks Dmitry,
>>>
>>> Is this what you meant?
>>> $.getJSON('http://localhost:5984/test/test?jsoncallback=?',
>>> function(data) { var e = '(' + data + ')';  
>>> alert(eval('(e._id)')); })
>>>
>>> It still doesn't work. Weird thing is I also get the "invalid label"
>>> even if I do nothing:
>>> $.getJSON('http://localhost:5984/test/test?jsoncallback=?',
>>> function(data) { })
>>>
>>> Ok, my Javascript/jQuery is yet very rusty, but I can't believe
>>> parsing json is so hard.
>>>
>>> And actually couldn't find any examples "with trailing \n" - all
>>> others seem to work well, like the flickr example i posted (granted
>>> the response already contains the parenthesis).
>>> No one else has been playing around with jQuery and CouchDB?
>>>
>>> Thanks again,
>>>
>>> Francisco
>>>
>>> 2009/6/18 Dmitry Unkovsky <oil.crayons@gmail.com>:
>>>
>>>>
>>>> eval('({"a":"b"})') is ok too, so you could just enclose response  
>>>> into
>>>> parentheses.
>>>>
>>>> 2009/6/18 Dmitry Unkovsky <oil.crayons@gmail.com>:
>>>>
>>>>>
>>>>> You get "invalid label" error when you are evaluating json  
>>>>> string as
>>>>> is, like eval('{"a":"b"}'),
>>>>> and eval('var a={"a":"b"}') is ok.
>>>>>
>>>>> Hope that helps.
>>>>>
>>>>> 2009/6/18 francisco treacy <francisco.treacy@gmail.com>:
>>>>>
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I'm trying to get something super simple running in Firefox, not
>>>>>> without problems.
>>>>>>
>>>>>> From a local html file I am using jQuery to make an ajax call to
>>>>>> CouchDB like so:
>>>>>>       $.getJSON('http://localhost:5984/test/test?jsoncallback=?',
>>>>>> function(data) { alert(data._id); })
>>>>>> but Firebug always shows an "invalid label" error, with the  
>>>>>> following
>>>>>> response: {"_id":"test","_rev":"1-1480939370"}\n
>>>>>>
>>>>>> For instance, this works ok:
>>>>>>
>>>>>> $.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?tags=cat&tagmode=any&format=json&jsoncallback=

>>>>>> ?',
>>>>>> function(data) { alert(data.title); })
>>>>>>
>>>>>> Also when I try with a local json file (just {title: "test"})  
>>>>>> it works
>>>>>> fine, when i put {title: "test"}\n , it doesn't.
>>>>>>
>>>>>> Could the trailing \n be the problem here? Any other pointers  
>>>>>> from
>>>>>> people who have tried parsing CouchDB's json with jQuery?
>>>>>>
>>>>>> Thanks in advance,
>>>>>>
>>>>>> Francisco
>>>>>>
>>>>>>
>>>
>>>
>>
>>
>


Mime
View raw message