0

So I'm not too sure if I'm going to be able to explain this in a way that someone will be able to help me but here it goes:

When I call the function getFishing() I want it to get the "username" Element and put it in a var called get_name, then I want it to send that variable over to the XML_Fishing.php file where is is then used in a mysql query which is then parsed to XML data which is then re-read by the fishingUrl() function. The issue right now is that it's not passing the get_name variable to the XML_Fishing.php file. Can anyone see why from the code below? I didn't give the entire fishingUrl function because it is not relevant to the passing of the variable. It's just the rest of the function, after the data is returned from the XML data.

 function getFishing(){
    var get_name = escape(document.getElementById("username").innerHTML);
    var name = "XML_Fishing.php?username=" + get_name;
    fishingUrl(name, "XML_Fishing.php", function(data) {
              ............
              ............
              ............
              }


function fishingUrl(name, url, callback) {
  var request = window.ActiveXObject ?
      new ActiveXObject('Microsoft.XMLHTTP') :
      new XMLHttpRequest;

  request.onreadystatechange = function() {
    if (request.readyState == 4) {
      request.onreadystatechange = doNothing;
      callback(request, request.status);
    }
  };

  request.open('GET', url, true);
  request.send(null);
}

1 Answer 1

1

name is not being passed to the AJAX request - try changing

fishingUrl(name, "XML_Fishing.php", function(data)

to

fishingUrl(name, name , function(data)

that will make first parameter redundant - unless it was being used in the callback function.

This will set $_GET['username'] in the PHP script to the value of get_name from the Javascript

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.