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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:03:45+00:00 2026-05-23T10:03:45+00:00

function getIDs() { alert(1); var title = document.getElementById(‘title’).value; alert(title); title = http://www.imdbapi.com/?i=&t= + title;

  • 0
function getIDs() {
alert("1");
var title = document.getElementById('title').value;
alert(title);
title = "http://www.imdbapi.com/?i=&t=" + title;
alert(title);
xmlhttp=new XMLHttpRequest();
alert("2");
xmlhttp.open("GET",title,true);
alert("3");
xmlhttp.send();
alert("4");
var imdbData = xmlhttp.responseText;
alert(imdbData);
var imdbJSON = JSON.parse(imdbData);
//document.getElementById('title').value = imdbJSON.Title;
alert(imdbJSON.Title);
document.getElementById('imdbid').value = imdbJSON.ID;
return true;
}

I’m trying to fetch the ID of a film based upon it’s title, the function gets called successfully and the alerts are correct until the alert which returns “imdbData”, which returns a blank alert, then no more alerts occur, I’m unsure where I’m going wrong here. Any assistance would be appreciated.

  • 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-23T10:03:46+00:00Added an answer on May 23, 2026 at 10:03 am

    You’re opening it asynchronously. To make it synchronous, change this:

    xmlhttp.open("GET",title,true);
    

    To this:

    xmlhttp.open("GET",title,false);
    

    A usually-considered-better way would be to make it work with asynchronicity:

    function getIDs() {
        alert("1");
        var title = document.getElementById('title').value;
        title = "http://www.imdbapi.com/?i=&t=" + title;
        xmlhttp=new XMLHttpRequest();
        xmlhttp.onreadystatechange=function() {
            if(xmlhttp.readyState==4) {
                var imdbData = xmlhttp.responseText;
                var imdbJSON = JSON.parse(imdbData);
                document.getElementById('title').value = imdbJSON.Title;
                document.getElementById('imdbid').value = imdbJSON.ID;
            }
        };
        xmlhttp.open("GET",title,true);
        xmlhttp.send();
        return true;
    }
    

    Additionally, you cannot request pages from other domains. You may need to switch to JSONP if the API you’re using supports it, or use your web server as a proxy.

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

Sidebar

Related Questions

<script language=javascript> function customFunction(url){ alert(url); //window.location = url; //document.all.url.checked = true; document.getElementById('url').checked = true;
$(document).ready(function() { redo(1); $(select).change(function () { var str = ; $(select option:selected).each(function () {
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
I have this code to send data: function insert_new_image() { var ids = [];
Here is my JS: function declassifyAjax(e) { var items = getSelected(); var docIds =
this is my code to fix compability getElementById in ie,ff,opera etc function getId(item) {
I have the following function: public function updateCustomerInternetBanking($value, $column_to_go_by) { $sql = UPDATE customer
My code is function getID( swfID ){ if(navigator.appName.indexOf(Microsoft) != -1){ me = window[swfID]; }else{
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///

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.