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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:21:44+00:00 2026-05-20T07:21:44+00:00

Have struggled with this call for a while now but i can’t get it

  • 0

Have struggled with this call for a while now but i can’t get it to work. dataToReturn still returns Error and not the called data. What am i doing wrong?

function get_translation(search) {
    search = search.replace(/(<([^>]+)>)/ig, "").toLowerCase();
    original = search;
    google.language.translate( original ,  'en', 'sv', 
    function(result) {
        translated = result.translation;
        $("#results").html('<li class="ui-li-has-icon ui-li ui-li-static ui-btn-up-c" role="option" tabindex="0">'+ translated + '</li>')   
    });
};

function get_synonyms(items) { 



var dataToReturn = "Error";  

$.ajax({
    url: 'http://words.bighugelabs.com/api/1/xxx/' + items+ '/json',
    type: 'GET',
    dataType: 'jsonp',
    async: false,
    cache: false,
    success: function(data) {

       dataToReturn = data;
    }
});


return dataToReturn;

}


$('#results').delegate("li", "tap", function(){
    myDate = new Date();
    displayDate = myDate.getDate() + "/" + myDate.getMonth()+1 + "/" + myDate.getFullYear();
    id = myDate.getTime();

    var wordObject = {'id' : id, 'date': displayDate, 'translated': translated, 'original': original, 'nmbr': "0", 'syn': get_synonyms('hello')};
    save_terms(wordObject);
    loopItems() ;
    $("#results").html("");
    $("#addField").val("");
    // location.reload(true);
}); 
  • 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-20T07:21:45+00:00Added an answer on May 20, 2026 at 7:21 am

    It’s because the return dataToReturn line is being executed before the AJAX call is complete. When you call $.ajax, the browser says, “Okay, I’ll just move on to the next thing while I’m waiting for that to get back to me.”

    The simplest way to fix this would be to change the success function to actually do whatever it is you’re trying to do with dataToReturn. But if that’s not really feasible, then more context would help come up with a better answer.

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

Sidebar

Related Questions

This is a very lame question, but I have struggled with it far too
I have struggled with this for a long time, and I did get a
I have spent hours Googling and searching past questions but have struggled to get
I have struggled a lot spent quiet a lot of time but unable to
I have struggled converting this SQL statement to LINQ to SQL VB.Net 9.0. I
I know that this is quite subjective, but is it something that I have
I have struggled and now I just need to see it in action. I
I have a problem that i've struggled with for a long time. This problem
With C++, I struggle to understand one compilation error. I have this function, with
I know that there have been plenty of topics describing this topic but I

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.