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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:12:41+00:00 2026-05-27T03:12:41+00:00

I need to receive a value of JSONP async request. When I assigning data

  • 0

I need to receive a value of JSONP async request. When I assigning “data” to global variable, I receive a empty object. Please, help me.

Now, I my code get

var url = "http://local/main/getEventData/" + event_id;
var script = document.createElement('script');
script.setAttribute('src', url);
document.getElementsByTagName('head')[0].appendChild(script);

var event_data = {};

function callback(data) {
    event_data = data;
}

and JSONP

callback({name: 'John'})

PS Request absolutely works and I can display data variable via console.log(data)

  • 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-27T03:12:42+00:00Added an answer on May 27, 2026 at 3:12 am

    Use the data when you get it, not (as I assume you are trying now) as soon as you’re requested it.

    function callback(data) {
        event_data = data;
        // Now you have the data, do something with it.
    }
    
    // Don't try to use event_data here. There's no way 
    // to know if the callback has fired yet
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to receive a AJAX request value, but alway receive undefined. Panda.Meals.getMealById =
I need to send and receive data over serial connections (RS-232 and RS-422). How
I need to receive the key press events during cell editing in DataGridView control.
The Problem: I need to receive different types of content from a number of
I am new to ruby. I need to receive password as an input through
I need to be able to receive a fax in a java application. I
I need a library that allows me to do email operations(e.g Sent/Receive mail) in
In order to send and receive encrypted messages from/to the iPhone I need to
I'm writing a small tool in C# which will need to send and receive
On success of a web service i receive a UUID. ie C3D668DC-1231-3902-49318B046AD48A5F I need

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.