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 9259939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:46:30+00:00 2026-06-18T12:46:30+00:00

Altering a JSON variable is failing for following snippet: var data = {status: ”};

  • 0

Altering a JSON variable is failing for following snippet:

var data = {status: ''};

rosconnection.setOnOpen(function (e) {
        data.status = 'Succeeded';
        alert('success');
});

rosconnection.setOnError(function (e) {
        data.status = 'Failed';
        alert('fail');
});

data stays empty, but the alert gets called within rosconnection.setOnOpen. The error is hard to replicate hence its used on a ros connection, but i am 100% certain that it enters atleast one of the functions with success.

  • 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-06-18T12:46:31+00:00Added an answer on June 18, 2026 at 12:46 pm

    You didn’t show us how you know the status didn’t change so…

    My bet is: there is no way you saw the alert without the data being changed so your code probably looks something like this:

    var data = {status: ''};
    
    rosconnection.setOnOpen(function (e) {
            data.status = 'Succeeded';
            alert('success');
    });
    
    rosconnection.setOnError(function (e) {
            data.status = 'Failed';
            alert('fail');
    });
    
    alert(data.status);
    

    So the status was not set yet. Check it inside the callback. AJAX…
    What does AJAX means? A is for async, which means it will fire sometime in the future(near or far), you can’t know when and sometimes don’t even if it will ever be called.

    Updated version:

    var data = {status: ''};
    
    rosconnection.setOnOpen(function (e) {
            data.status = 'Succeeded';
            alert(data.status);
    });
    
    rosconnection.setOnError(function (e) {
            data.status = 'Failed';
            alert(data.status);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am altering the question now! I have the search working using the following:
Is there a way of doing this without altering the function? function foo(bar1, bar2,
I'm following the NeHe gamedev tutorials (while altering them to be OO) and I've
Im having problem altering jQuerys beforeunload() functionality, depending on user actions. $(document).ready(function() { $(window).bind('beforeunload',
I have a package and am debating altering the code of a function. I
This question is about altering how the Grails data-binding handles string-to-integer conversion. Consider the
i use a readonly collection to prevent users from altering my cached data, but
I'm trying to change what the stored procedure returns without altering data. I'm trying
this PHP RGB brightness altering function works partially: It misses one zero 0 at
While altering a table (removing a column) in SQL Server 2008, I clicked the

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.