[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-11 Thread Leonel Câmara
Seems like you're trying to make a phonegap/cordova app, the easiest way to 
go around the CORS problem is to simply put the web version of your app 
inside web2py's static folder. As a packaged application on your phone you 
will not have this problem.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-11 Thread Anthony
On Friday, November 11, 2016 at 1:15:58 PM UTC-5, Mike Stephenson wrote:
>
> Yeah exactly that doesn't work. How do I avoid that error? It says:" 
> XMLHttpRequest cannot load 
> https://biglibrary.pythonanywhere.com/app/phonegap/temp.json. No 
> 'Access-Control-Allow-Origin' header is present on the requested resource. 
> Origin 'null' is therefore not allowed access." when I use your code 
> snippet.
>

In the future, please explain in more detail what you are trying to do and 
show any code you have tried along with any error messages.

Note, browsers will not allow you to make Ajax requests to other domains 
(i.e., cross-origin requests) unless CORS has been set up with those 
servers (do some research on CORS).

An alternative is to make an Ajax request to *your own server*, and have 
your server then make the request for the resource in question and simply 
pass it back to the browser.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-11 Thread Mike Stephenson
Yeah exactly that doesn't work. How do I avoid that error? It says:" 
XMLHttpRequest cannot load 
https://biglibrary.pythonanywhere.com/app/phonegap/temp.json. No 
'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'null' is therefore not allowed access." when I use your code 
snippet.

On Friday, November 11, 2016 at 11:33:11 PM UTC+5:30, Leonel Câmara wrote:
>
> $.getJSON("https://biglibrary.pythonanywhere.com/app/phonegap/temp.json 
> 
> ").then(function(data) {
> alert(data.message);
>
> });
>
> Note that you may have problems with Access-Control-Allow-Origin
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-11 Thread Leonel Câmara
$.getJSON("https://biglibrary.pythonanywhere.com/app/phonegap/temp.json 

").then(function(data) {
alert(data.message);

});

Note that you may have problems with Access-Control-Allow-Origin

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-11 Thread Mike Stephenson
Not that. Using javascript only how do I parse the json fron this link: 
https://biglibrary.pythonanywhere.com/app/phonegap/temp.json 


On Friday, November 11, 2016 at 7:05:00 PM UTC+5:30, Anthony wrote:
>
> On Friday, November 11, 2016 at 7:29:06 AM UTC-5, Mike Stephenson wrote:
>>
>> Hi Dave. for example how do I read the json from this link: 
>> https://biglibrary.pythonanywhere.com/app/phonegap/temp.json 
>> 
>>
>
> If you have that as a string in Python and want to convert it to a Python 
> object (i.e., a dictionary):
>
> import json
> mydict = json.loads(my_json_string)
>
> Anthony
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-11 Thread Anthony
On Friday, November 11, 2016 at 7:29:06 AM UTC-5, Mike Stephenson wrote:
>
> Hi Dave. for example how do I read the json from this link: 
> https://biglibrary.pythonanywhere.com/app/phonegap/temp.json
>

If you have that as a string in Python and want to convert it to a Python 
object (i.e., a dictionary):

import json
mydict = json.loads(my_json_string)

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-11 Thread Mike Stephenson
Hi Dave. for example how do I read the json from this 
link: https://biglibrary.pythonanywhere.com/app/phonegap/temp.json

A code snippet will be of much help.
Thanks. :)

On Friday, November 11, 2016 at 12:34:26 AM UTC+5:30, Dave S wrote:
>
>
>
> On Wednesday, November 9, 2016 at 9:24:02 PM UTC-8, Mike Stephenson wrote:
>>
>> It's messed up.
>>
>
> How so?  What does it do?  What do you expect it to do?
>
> Can you show us how your controller prepares the json?  What does your 
> view look like?
>  
>
>> Can you help out with a code snippet? Will be of much help.
>>
>
> Does this one help?
>  http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#Voting-and-rating
> >
>
> /dps
>  
>
>> On Thursday, November 10, 2016 at 12:17:17 AM UTC+5:30, Leonel Câmara 
>> wrote:
>>>
>>> What do you mean? What are you trying to do? How are you putting the 
>>> json there? Are you getting it using $.getJSON or something like that?
>>>
>>
>  
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-10 Thread Dave S


On Wednesday, November 9, 2016 at 9:24:02 PM UTC-8, Mike Stephenson wrote:
>
> It's messed up.
>

How so?  What does it do?  What do you expect it to do?

Can you show us how your controller prepares the json?  What does your view 
look like?
 

> Can you help out with a code snippet? Will be of much help.
>

Does this one help?
http://web2py.com/books/default/chapter/29/11/jquery-and-ajax#Voting-and-rating>

/dps
 

> On Thursday, November 10, 2016 at 12:17:17 AM UTC+5:30, Leonel Câmara 
> wrote:
>>
>> What do you mean? What are you trying to do? How are you putting the json 
>> there? Are you getting it using $.getJSON or something like that?
>>
>
 

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-09 Thread Mike Stephenson
It's messed up.
Can you help out with a code snippet? Will be of much help.

On Thursday, November 10, 2016 at 12:17:17 AM UTC+5:30, Leonel Câmara wrote:
>
> What do you mean? What are you trying to do? How are you putting the json 
> there? Are you getting it using $.getJSON or something like that?
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[web2py] Re: I am unable to parse contents from a json view in javascript? How do I do it?

2016-11-09 Thread Leonel Câmara
What do you mean? What are you trying to do? How are you putting the json 
there? Are you getting it using $.getJSON or something like that?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.