Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Great work, more examples!
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
alxsti3@googlemail.com  
View profile  
 More options Sep 5 2008, 1:28 am
From: "alxs...@googlemail.com" <alxs...@googlemail.com>
Date: Thu, 4 Sep 2008 22:28:37 -0700 (PDT)
Local: Fri, Sep 5 2008 1:28 am
Subject: Great work, more examples!
I just wanted to say what fantastic work I think this is. I've been
intrigued by all of this since hearing about 280slides on the Ajaxian
podcast a few month ago.

The code examples in the PhotoDemo and Puzzle are useful. I think a
useful addition would be a very simple example demonstrating the use
of server communication/RPC/JSON etc.

Something really simple like loading table with 10 rows of data would
be a good starting point for me, personally.

I'll post something if I get there before one of the experts does.

Alex


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eisen Montalvo  
View profile  
 More options Sep 5 2008, 2:15 am
From: Eisen Montalvo <ei...@mac.com>
Date: Thu, 04 Sep 2008 23:15:45 -0700
Local: Fri, Sep 5 2008 2:15 am
Subject: Re: Great work, more examples!
I just finished a quick test to connect to a backend using JSON to get  
the data and POST to send the data back. Is is basically a hack, but  
will give you the idea.

To connect to a php backend script:
        var url = baseUrl + "jsonScript.php";
        var request = [CPURLRequest requestWithURL: url];
        var data = [CPURLConnection sendSynchronousRequest: request  
returningResponse:nil error:nil];
        var str = [data description];

'str' will contain a JSON object or array that you will need to  
decode. I hope somebody adds a method to CPData to convert a JSON  
object to a CPArray or CPDictionary.

To send data back to a php backend script using POST:
        var url = baseUrl + "postScript.php";
        var request = [CPURLRequest requestWithURL: url];
        var body = "field1=" + field1Value + "&field2=" + field2Value +  
"&field3=" + field3Value;

        [request setHTTPMethod: "POST"];
        [request setValue:"application/x-www-form-urlencoded"  
forHTTPHeaderField:"Content-Type"];
        [request setValue:[body length] forHTTPHeaderField:"Content-Length"];

        [request setHTTPBody: body];

        var data = [CPURLConnection sendSynchronousRequest: request  
returningResponse:nil error:nil];

'data' contains any results sent back from the script that you can use  
to validate the results of the operation.

This are synchronous connections. I haven't tried with asynchronous  
yet, but I'll be playing with them soon. I'm pretty sure there are  
better ways to handle the connection to the backend, I'm not an  
expert. I just wanted to share some code that might help you.

Eisen

On Sep 4, 2008, at 10:28 PM, alxs...@googlemail.com wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Hoffman  
View profile  
 More options Sep 5 2008, 6:18 am
From: "Kevin Hoffman" <aloth...@gmail.com>
Date: Fri, 5 Sep 2008 06:18:48 -0400
Local: Fri, Sep 5 2008 6:18 am
Subject: Re: Great work, more examples!
There's a JSON connector already written for us in the Flickr demo
source code. Might make some of this easier.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eisen Montalvo  
View profile  
 More options Sep 5 2008, 9:13 am
From: Eisen Montalvo <ei...@mac.com>
Date: Fri, 05 Sep 2008 06:13:06 -0700
Local: Fri, Sep 5 2008 9:13 am
Subject: Re: Great work, more examples!
Thank you Kevin. On my first glance at the demos I didn't notice the  
link to the source code. Would've saved some time! :-) Anyway it was  
fun. I love working with Cappuccino.

Eisen

Sent from my iPhone 3G

On Sep 5, 2008, at 3:18 AM, Kevin Hoffman <aloth...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alxsti3@googlemail.com  
View profile  
 More options Sep 5 2008, 6:44 am
From: "alxs...@googlemail.com" <alxs...@googlemail.com>
Date: Fri, 5 Sep 2008 03:44:49 -0700 (PDT)
Local: Fri, Sep 5 2008 6:44 am
Subject: Re: Great work, more examples!
Yes, I found CPJSONPConnection.j. Have modified the Hello World
example to request the text from a server.
The one thing that caught me out was having to wrap the returned JSON
as named by the jsoncallback GET parameter, i.e. $_GET['jsoncallback']
( {...} ).

-(void)connection:(CPJSONPConnection)aConnection didReceiveData:
(CPString)data
{
        [label setStringValue:"Received: "+data.greeting];

}

-(void)connection:(CPJSONPConnection)aConnection didFailWithError:
(CPString)error
{
    alert(error);

}

-(void)swap:(id)sender {
    var request = [CPURLRequest requestWithURL:"hello.php"];
    var connection = [CPJSONPConnection sendRequest: request callback:
"jsoncallback" delegate: self];

}

(Apologies if this appears twice, not sure where my posts are
going...)

On 5 Sep, 11:18, "Kevin Hoffman" <aloth...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alxsti3@googlemail.com  
View profile  
 More options Sep 5 2008, 6:34 am
From: "alxs...@googlemail.com" <alxs...@googlemail.com>
Date: Fri, 5 Sep 2008 03:34:48 -0700 (PDT)
Local: Fri, Sep 5 2008 6:34 am
Subject: Re: Great work, more examples!
Yeah, I discovered CPJSONPConnection.j as used in the photo demo.

The below code is based on the Hello world example. It assumes a JSON
string is returned by hello.php that looks like the following:

{ "greeting":"Hello from request."}

You need to wrap the JSON as named by the jsoncallback GET parameter.
i.e.

<?=$_GET['jsoncallback']?>(  { "greeting":"Hello from request."} )

AppController is passed as a delegate to handle the response when it
arrives, so these two methods are needed.

-(void)connection:(CPJSONPConnection)aConnection didReceiveData:
(CPString)data
{
        [label setStringValue:"Received: "+data.greeting];

}

-(void)connection:(CPJSONPConnection)aConnection didFailWithError:
(CPString)error
{
    alert(error);

}

-(void)swap:(id)sender {
    var request = [CPURLRequest requestWithURL:"hello.cfm"];
    var connection = [CPJSONPConnection sendRequest: request callback:
"jsoncallback" delegate: self];

}

Hope this helps if anyone was unsure, as I was!

Alex

On Sep 5, 11:18 am, "Kevin Hoffman" <aloth...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alxsti3@googlemail.com  
View profile  
 More options Sep 5 2008, 3:53 am
From: "alxs...@googlemail.com" <alxs...@googlemail.com>
Date: Fri, 5 Sep 2008 00:53:51 -0700 (PDT)
Local: Fri, Sep 5 2008 3:53 am
Subject: Re: Great work, more examples!
Thanks, that's helpful. I have since found that the photo demo and
CPJSONPConnection.j answers a lot of my questions regarding
asynchronous communication.

On Sep 5, 7:15 am, Eisen Montalvo <ei...@mac.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Robinson  
View profile  
 More options Sep 5 2008, 2:38 pm
From: Tom Robinson <t...@280north.com>
Date: Fri, 5 Sep 2008 13:38:02 -0500
Local: Fri, Sep 5 2008 2:38 pm
Subject: Re: Great work, more examples!
Actually CPJSONPConnection is meant for JSONP APIs like Flickr (JSONP  
is a method used to circumvent the browser's same origin policy)

You should use CPURLConnection (a thin wrapper around XMLHttpRequest)  
and parse the result using CPJSObjectCreateFromJSON() (essentially  
"eval" with checks to make sure the input is valid JSON)

You won't need to do the JSONP style wrapping with this method.

(btw the reason your posts didn't show up is posts by new members need  
to be approved. We should turn that off though)

Sent from my iPhone

On Sep 5, 2008, at 5:44 AM, "alxs...@googlemail.com" <alxs...@googlemail.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
alxsti3@googlemail.com  
View profile  
 More options Sep 5 2008, 3:36 pm
From: "alxs...@googlemail.com" <alxs...@googlemail.com>
Date: Fri, 5 Sep 2008 12:36:23 -0700 (PDT)
Local: Fri, Sep 5 2008 3:36 pm
Subject: Re: Great work, more examples!
Ahh, that clears that up.

Thanks. I think this info would make a good wiki page as it's the kind
of basic thing people want to do after getting 'Hello World!'
working.

On Sep 5, 7:38 pm, Tom Robinson <t...@280north.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google