0

i have a simple HTML, where on a tag i have onmouseover="loadQueryResults();"

Here is a function:

function loadQueryResults(e) {
    e = e || window.event;
    var data = [];
    var target = e.srcElement || e.target;
    while (target && target.nodeName !== "TR") {
        target = target.parentNode;
    }
    if (target) {
        var cells = target.getElementsByTagName("td");
        for (var i = 0; i < cells.length; i++) {
            data.push(cells[i].innerHTML);

        }
    }
    //window.open("racun.php?name="+data) THIS WORKS
    //window.alert("racun.php?name=" + data) THIS WORKS
    //document.writeln(data);
    final=data.toString();
    //document.writeln(final); THIS ALSO WORKS
    stranica="racun.php?name="+final;
    $( "#DisplayDiv" ).load(stranica); //THIS DOESNT WORK---WHY???
    $( "#DisplayDiv" ).load("racun.php"); //THIS however WORKS!
}  

Question is, why when i include arguments in php page i want to load, nothing happens?

2
  • 1
    Did you checked you racun.php script ? Does it work in browser when you call it with a parameter ? Commented Jul 16, 2014 at 9:37
  • It does. And it works with window.open() function...it just doesnt with $("div").load()... Commented Jul 16, 2014 at 9:54

2 Answers 2

1

i think cells[i].innerHTML has space or characters that not allowed in url!

u should use this function to filter 'final' variable:

final = encodeURIComponent( data.toString() );
Sign up to request clarification or add additional context in comments.

Comments

1

Try to pass params according to jQuery docs:

$( "#DisplayDiv" ).load("racun.php", {name: data.toString() });

And "final" looks like reserved word

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.