Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
process further
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
  7 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
 
chrysanthem  
View profile  
 More options Jul 8, 7:17 am
From: chrysanthem <chrysant...@gmail.com>
Date: Wed, 8 Jul 2009 04:17:05 -0700 (PDT)
Local: Wed, Jul 8 2009 7:17 am
Subject: process further
Hello
On return from a ajax call with prototype, is it possible to send the
return parameters to a function to be processed first and then write
that return value to the designated element?  Also where is the syntax
on how to write the return values?  I am having difficulty
understanding what I can use as text and what I can use as a
variable.  tia.

    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.
David Behler  
View profile  
 More options Jul 8, 12:25 pm
From: David Behler <d.beh...@gmail.com>
Date: Wed, 8 Jul 2009 09:25:19 -0700 (PDT)
Local: Wed, Jul 8 2009 12:25 pm
Subject: Re: process further
I guess you would have to use Ajax.Request to process the returned
value before updating the designated element.

But I'm beginner and could be wrong here.


    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.
chrysanthe m  
View profile  
 More options Jul 8, 10:37 pm
From: chrysanthe m <chrysant...@gmail.com>
Date: Wed, 8 Jul 2009 22:37:55 -0400
Local: Wed, Jul 8 2009 10:37 pm
Subject: Re: [Proto-Scripty] Re: process further

Hi David
Thanks, but I think I one step further.  I am assuming an Ajax.request() has
happened, returned and what I am looking at to understand further is syntax
like this:
$('fullName').value = json.fullName;
for an returned parameter fullName and an html element ID of fullName. I am
wondering, can I do
$('fullName').value =processMe( json.fullName);
which I know the obvious is try it.  I will, just trying to get an heads
up.  I will report back.  Also I am assuming that prototpye is processing
that nomenclature $('fullName') segment and just doing a
document.getElementById.  Any insight appreciated.


    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.
Douglas  
View profile  
 More options Jul 9, 12:38 am
From: Douglas <douglas.gont...@gmail.com>
Date: Thu, 9 Jul 2009 01:38:07 -0300
Local: Thurs, Jul 9 2009 12:38 am
Subject: Re: [Proto-Scripty] Re: process further
Hello,
all you have to do (I guess) is set a callback to onComplete.
Something as follow:

// onComplete callback's call
function processJsonPart (myCoolVar)
{
    // do something with your returned JSON
    return myCoolVarEvaluatedOrValidatedOrAnythingYouWant;

}

// here we call Ajax.request
function clickButtonExample()
{
    new Ajax.Request(url, {
        onComplete: function(r)
        {
            var json = r.responseText.evalJSON(true);
            $('name').value = foo(json.name);
        }
    }

}

PS: untested functions.

--
Believe nothing, no matter where you read it, or who said it, no
matter if I have said it, unless it agrees with your own reason and
your own common sense.

    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.
Douglas  
View profile  
 More options Jul 9, 12:39 am
From: Douglas <douglas.gont...@gmail.com>
Date: Thu, 9 Jul 2009 01:39:32 -0300
Local: Thurs, Jul 9 2009 12:39 am
Subject: Re: [Proto-Scripty] Re: process further
oops!

'foo' should be 'processJsonPart'

--
Believe nothing, no matter where you read it, or who said it, no
matter if I have said it, unless it agrees with your own reason and
your own common sense.

    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.
sathvik  
View profile  
 More options Jul 9, 12:24 am
From: sathvik <sathvikm...@gmail.com>
Date: Thu, 9 Jul 2009 09:54:54 +0530
Local: Thurs, Jul 9 2009 12:24 am
Subject: Re: [Proto-Scripty] Re: process further

Hi,
I am a newbie too , but I think if processMe() is method of a class , u can
call that method using 'this' like
$('fullname').value = this.processMe(parameter);


    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.
T.J. Crowder  
View profile  
 More options Jul 9, 8:41 am
From: "T.J. Crowder" <t...@crowdersoftware.com>
Date: Thu, 9 Jul 2009 05:41:05 -0700 (PDT)
Local: Thurs, Jul 9 2009 8:41 am
Subject: Re: process further
Hi,

> ...like this:
> $('fullName').value = json.fullName;
> for an returned parameter fullName and an html element ID of fullName.

It would be helpful if you gave a more thorough explanation of what
you're looking to do.  But, just for the sake of an example, let's
assume:

1. You are sending back properly-formatted JSON with the correct MIME
type in response to an Ajax.Request.

2. The JSON data will have a success flag and firstName and lastName
properties, like this:

{
    'success':    true,
    'firstName':  'Joe',
    'lastName':   'Bloggs'

}

3. You want to display the names in the format "firstName lastName" in
an element that already exists on the page with the ID "fullName".

Here's how you can do that:

function showError(errmsg) {
    alert(errmsg); // or whatever

}

function showName(elm, obj) {
    elm.update(json.firstName + " " + json.lastName);

}

new Ajax.Request(url, {
    // Success handler
    onSuccess: function(response) {
        var json, elm;

        // Get the object containing the data from the request.
        // Since you returned it with the correct content type
(application/json),
        // Prototype has _already_ deserialized it for you and put it
in the
        // member 'responseJSON'.  (You don't need to use evalJSON()
unless
        // you're not setting the content type correctly.)
        json = response.responseJSON;

        // Check that the JSON was returned
        if (!json || !json.success) {
            showError("Couldn't get the name.");
        } else {
            // Get the "fullName" element
            elm = $('fullName');
            if (!elm) {
                // Show an error?  The element is missing.
            } else {
                // Set its content from the JSON data
                showName(elm, json);
            }
        }
    },

    // Failure handler
    onFailure: function(response) {
        showError("Error getting the name from the server.");
    }

});

Hopefully that'll get you headed the right way.  Although it doesn't
talk about JSON, this article[1] on the unofficial wiki may also be
helpful in terms of bulletproofing your Ajax requests.

[1] http://proto-scripty.wikidot.com/prototype:how-to-bulletproof-ajax-re...

HTH,
--
T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Jul 9, 3:37 am, chrysanthe m <chrysant...@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.
End of messages
« Back to Discussions « Newer topic     Older topic »

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