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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:44:15+00:00 2026-06-17T03:44:15+00:00

I am making a phonegap app for android. I am receiving a json string

  • 0

I am making a phonegap app for android. I am receiving a json string and trying to parse it . It’s a very small data.
{"result":{ "node":"32"}
}

if iam using alert(request.responseText)
the result is displayed but if i return this request.responseText to the calling function and collect it there in a variable like var x= somefunction(); x contains undefined.

var jsonObj = sendPostRequest(url,nurl);
  console.log(jsonObj+""); // GIVES UNDEFINED HERE AT THIS LINE BUT SAME STATEMENT WORKS IN sendPostRequest()
  if(jsonObj){
    var Json = JSON.parse(jsonObj);
    console.log(json);
    document.getElementById("gnodei").innerHTML= json.result.wEventId;
  }

I can collect this response in a variable y inside somefunction() but on returning this data to the calling function nothing reaches there. I use the above json data x just below it but it doesn’t work.

please suggest.

edit: `function sendPostRequest(url,nurl){

var request = new XMLHttpRequest();
request.onreadystatechange = function() {
       if (request.readyState == 4) {
        if (request.status == 200 || request.status == 0){
           console.log(request.status);
           //alert(request.responseText);
           var txt= request.responseText;
           console.log(txt);
           return txt;
          }
        }
      }

request.open("POST",url, true);
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request.send(nurl);

}`

The ajax call. Also there are multiple functions calling this ajax call after preparing their url and nurl values so i need this function as it is. I only need to know how to get back the response in my calling function.
Thanks

  • 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-17T03:44:17+00:00Added an answer on June 17, 2026 at 3:44 am

    Solved it: Created a function to be passed as callback to the sendPostRequest(url,nurl) method. This callback is called only after the ajax call finishes as correct status. The callback function assigns the data that can be used thereafter.

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

Sidebar

Related Questions

I am trying to implement a Codeigniter based app on Android via phonegap, all
Am making a basic phonegap based android app. All working perfectly and using localstorage
I am writing a PhoneGap app on Android. I am trying to stay pure
I'm developing an android app with phonegap. I'm making an HTML table with some
I'm making an Android app using Eclipse, phonegap (version 2.1.0) and html5. I'm encountering
i'm making an app for ios and android using phonegap and html. In my
I'm making an App with Cordova-Phongap 1.9.0 on Android, using Jquery Mobile. I'm trying
I'm making a Phonegap app and need to retrieve some information from an external
I'm making a web-app with PhoneGap. Here's my current hurdle: On page one, the
I'm making a mobile app using phonegap. That is to say, it's all done

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.