Jump to content

XMLHttpRequest, url file not being called


GeorgeHS
 Share

Recommended Posts

I have a Java script named “modifymember.js”

If contains a function named “function showmember(str)”.

This function calls file “getmemberlastname.php” passing it a string with the member’s last name as a parameter

The function code looks like this:

 function showmember(str)

{          

  if(str.length == 0)

  {

    return;

  }

  else

  {

var xmlhttp = new XMLHttpRequest();

            var rtn = "getmemberlastname.php?q=" + str; 

             xmlhttp.onreadystatechange = function()

            {

                        alert("this.readyState = " + this.readyState + " this.status = " + this.status);

                         if (this.readyState == 4 && this.status == 200)

                        {

                                    var responsedata = jQuery.parseJSON(this.responseText);

                                               

                        document.getElementById("userid").value = responsedata[1];

                                    document.getElementById("lastname1").value = responsedata[3];

                                    document.getElementById("firstname1").value = responsedata[4];

                                    …….

                        }

            }          

             xmlhttp.open("PUT", rtn, true);

             xmlhttp.send();

  }

 

When the str contains an apostrophe getmemberlastname.php does not get called.

Without an apostrophe it does get called and works correctly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...