Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6753957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:13:24+00:00 2026-05-26T13:13:24+00:00

I save the value of a textarea id=save inside addEventListener . Then, I send

  • 0

I save the value of a textarea id="save" inside addEventListener. Then, I send it to the server with xhr and at the same time I open a channel by using Google App Engine Channel API, then I am trying to capture the message sent back with onMessage.

Everything works, except the returned message. I understand that the returned message will be evt.data but it is not logged. Can you help me understand what I am doing wrong? This is a follow up to my previous question. Thanks!

document.getElementById("save").addEventListener
(
    "click", 
    function ()
    {
        var userEmail = document.getElementById("getEmail").value;
        var formData = new FormData();
        formData.append("extension_user", userEmail);

        var channel;
        var socket;
        var handler = 
        {
            //I changed this to "onmessage" as draevor's answer but 
            //I still don't see "evt.data" logged
            onMessage: function (evt)
            {
                //evt.data will be what the server sends in channel.send_message
                console.log("evt.data received from authhandler: " + evt.data);
                alert("evt.data is: " + evt.data)
            }
        };    

        var xhr = new XMLHttpRequest();
        xhr.onReadyStateChange = function()
        {   
            //this alert does not trigger
            alert("xhr.onReadyStateChange")
            if (xhr.readyState == 4 && xhr.status == 200)
            {
                token = xhr.responseText;
                //this alert does not trigger
                alert("token: " + token)
                channel = new goog.appengine.Channel(token);
                socket = channel.open(handler);
            }
        };
        xhr.open("POST", "http://ting-1.appspot.com/authsender", true);
        xhr.send(formData);
        console.log("formData sent to authsender: " + formData);

    }, false
)

UPDATE

Update as suggested by draevor’s answer I added other properties of onmessage. I followed this question although I am not sure why he puts the properties in single quotes.

document.getElementById("save").addEventListener
(
    "click", 
    function ()
    {
        var userEmail = document.getElementById("getEmail").value;
        var formData = new FormData();
        formData.append("extension_user", userEmail);

        var channel;
        var socket;
        var handler = 
        {
            onopen: onOpen,
            onmessage: onMessage,
            onerror: onError,
            onclose: onClose
        };    

        var xhr = new XMLHttpRequest();
        xhr.onReadyStateChange = function()
        {
            //this alert does not trigger
            alert("xhr.onReadyStateChange")
            if (xhr.readyState == 4 && xhr.status == 200)
            {
                token = xhr.responseText;
                //this alert does not trigger
                alert("token: " + token)
                channel = new goog.appengine.Channel(token);
                socket = channel.open(handler);
            }
        };
        xhr.open("POST", "http://ting-1.appspot.com/authsender", true);
        xhr.send(formData);
        console.log("formData sent to authsender: " + formData);
    }, false
)
onMessage = 
function (evt)
{
    //evt.data will be what the server sends in channel.send_message
    console.log("evt.data received from authhandler: " + evt.data);
    alert("evt.data is: " + evt.data)
}

onOpen =
function ()
{
    alert("onOpen")
}

onError =
function ()
{
    alert("onError")
}

onClose =
function ()
{
    alert("onClose")
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:13:25+00:00Added an answer on May 26, 2026 at 1:13 pm

    I think the problem is simply having named the property onMessage instead of onmessage. I would also suggest setting all the other properties (onopen, onerror, onclose), at least for debugging purposes in case the above doesn’t solve your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using YUI editor. I tried to fetch the textarea value and save
In WPF, where can I save a value when in one UserControl, then later
I am using ruby key & value fields to save a jquery function to
Check input tag which have value only as <br/> tag inside as value using
How to save exact whitespace count between words from textarea when putting it's value
I Want to save the value of an inplace if it was changed. The
I'm trying to save the value of each pixel in a gray scale image
I have been trying to use/save the boolean value of a checkbox in other
I'm making an android app, and I need to save the double value(BodySize) to
I have a value int called score and i want to save this to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.