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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:47:23+00:00 2026-06-04T14:47:23+00:00

Below is a very simple AJAX request that works just fine until I put

  • 0

Below is a very simple AJAX request that works just fine until I put a simple statement inside of it. It’s failing because of line #4.

var wlen = str.value.length

Below is the AJAX code

<script type="text/javascript">
function name_search(str)
{
var wlen = str.value.length;
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("name_div").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","/it/device/action/name_search_new.php?q="+str,true);
xmlhttp.send();
}
</script>

The name_search_new.php page looks up similar values to what is typed in the text box and returns those values. This page is irrelevant to this issue though because any php page will always fail with the line 4 new variable/assignment and it will always work with the variable/assignment gone.

If it helps, the request for this function is listed below… It also fails within a ‘textarea’ box too.

<input type="text" name="name" id="name" value="" style="color:red" 
placeholder="Device/Item(Required)" onkeyup="name_search(this.value)" />

Any help is appreciated,
Jay

  • 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-04T14:47:25+00:00Added an answer on June 4, 2026 at 2:47 pm

    You don’t need to do str.value.length. str.length is what you need.

    here is a jsfiddle demonstrating:

    http://jsfiddle.net/ahEeH/

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

Sidebar

Related Questions

I have written a very simple WCF service, that worked fine (code below), then
What would a very simple while loop statement be that would continue the below
I have some very simple code below that I can't get to validate on
Very simple Ajax request taking employee id and returning the user info as HTML
Below is a very simple bit of code that mimics a class structure in
I've got some very simple code below that I want to use as a
I have this very simple control below. And on the page that i use
Below is a very simple controller with a search action that is fired from
I have a very simple text input (below) that asks for the users email.
The below code is very simple. I have a jQuery autocomplete bound to an

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.