Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post

    XML filtering predicate operator called on incompatible function..

    Can anyone tell me what I'm doing wrong here?

    HTML

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title>Lottery Selector</title>
    <script language="javascript" type="text/javascript" src="javascript.js"></script>
    </head>
    
    <body bgcolor="#ffffff">
    
    <form name="form1">
    <input type="button" name="generate" value="Generate Lottery Selections" onclick="generate_numbers();" />
    &nbsp;
    <span id="selections">
    <input type="text" name="selection_field" size="30" />
    </span>
    </form>
    
    </body>
    </html>
    JavaScript:

    Code:
    function so_clearInnerHTML(obj) {
    	while(obj.firstChild) obj.removeChild(obj.firstChild);
    }
    
    var xmlHttp
    
    function generate_numbers()
    {
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
      {
      alert ("Your browser does not support AJAX!");
      return;
      }
    var url="gadget.php";
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.send(null);
    }
    
    function stateChanged()
    {
    if (xmlHttp.readyState==4)
    {
    var mr_data = xmlHttp.responseText;
    so_clearInnerHTML(document.getElementById("selections"));
    var foo = document.getElementById.("selections"); // This is the problem line
    e_node = document.createElement('text');
    e_node.setAttribute('name','selection_field');
    e_node.setAttribute('size',30);
    e_node.setAttribute('value',mr_data);
    foo.appendChild(e_node);
    }
    }
    
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttp;
    }
    Cheers!

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    what is with the period in there?

    document.getElementById.("selections");

    Remove that...

    If you have not done so already. Install Firefox and than install the Firebug extension http://www.getFirebug.com, it will make debugging JavaScript a lot easier.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    Hehe thanks that fixed it... silly mistake by me! But now for some reason I am not getting the result I was hopping for.... the box just disappears & doesn't come back with the data I was trying to put into it.... I had this working fine using innerHTML with FF; but it didn't work with IE properly (on the second push of the button) it wouldn't update again..... it would always stay the same value so I tried doing it this way.

  • #4
    Regular Coder
    Join Date
    Feb 2005
    Posts
    679
    Thanks
    0
    Thanked 16 Times in 15 Posts
    Since you are creating an input element
    Code:
    e_node = document.createElement('text');
    You should be using 'input'

    Code:
    e_node = document.createElement('input');
    e_node.setAttribute('type','text');
    You use 'var xmlHttp' twice. Drop the var in the GetXmlHttpObject function as xmlHttp needs to be global to be used by other functions
    Code:
    var xmlHttp;
    
    function generate_numbers()
          .....
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    Since you do not check the response , you may want to alert it to verify you are getting what you expect.

  • #5
    Regular Coder
    Join Date
    Apr 2004
    Posts
    682
    Thanks
    24
    Thanked 1 Time in 1 Post
    Hehe yeah.. I just worked out about the input tag problem..... another silly mistake by me hehe.... cheers!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •