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.
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;
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:
> 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.
On Fri, Sep 5, 2008 at 2:15 AM, Eisen Montalvo <ei...@mac.com> wrote:
> 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;
> 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:
>> 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.
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:
> There's a JSON connector already written for us in the Flickr demo > source code. Might make some of this easier.
> On Fri, Sep 5, 2008 at 2:15 AM, Eisen Montalvo <ei...@mac.com> wrote:
>> 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;
>> 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:
>>> 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.
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']
( {...} ).
> There's a JSON connector already written for us in the Flickr demo
> source code. Might make some of this easier.
> On Fri, Sep 5, 2008 at 2:15 AM, Eisen Montalvo <ei...@mac.com> wrote:
> > 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;
> > 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:
> >> 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.
> There's a JSON connector already written for us in the Flickr demo
> source code. Might make some of this easier.
> On Fri, Sep 5, 2008 at 2:15 AM, Eisen Montalvo <ei...@mac.com> wrote:
> > 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;
> > 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:
> >> 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.
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:
> 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;
> 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:
> > 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.
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
> 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'] > ( {...} ).
> (Apologies if this appears twice, not sure where my posts are > going...)
> On 5 Sep, 11:18, "Kevin Hoffman" <aloth...@gmail.com> wrote: >> There's a JSON connector already written for us in the Flickr demo >> source code. Might make some of this easier.
>> On Fri, Sep 5, 2008 at 2:15 AM, Eisen Montalvo <ei...@mac.com> wrote:
>>> 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;
>>> 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:
>>>> 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.
> 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
> > wrote:
> > 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']
> > ( {...} ).
> > (Apologies if this appears twice, not sure where my posts are
> > going...)
> > On 5 Sep, 11:18, "Kevin Hoffman" <aloth...@gmail.com> wrote:
> >> There's a JSON connector already written for us in the Flickr demo
> >> source code. Might make some of this easier.
> >> On Fri, Sep 5, 2008 at 2:15 AM, Eisen Montalvo <ei...@mac.com> wrote:
> >>> 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;
> >>> 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:
> >>>> 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.