Reputation: 501
I'm trying to call another page with javascript, but I can't imagine what is wrong. This is what I wrote:
function updatesomething(id) {
var xmlHttp = null;
var theUrl = "";
xmlHttp = new XMLHttpRequest();
alert('works');
theUrl = 'testpage.php?id=' + id + '&hoeveelheid=' + document.getElementById("hoeveelheid_textfield").value;
alert(theUrl);
xmlHttp.open("GET", theUrl, false);
xmlHttp.send(null);
}
The first alert that shows 'works', is actually working. The second alert never shows up. But I don't know what would be wrong with assignment of 'theUrl'.
Thanks
Upvotes: 0
Views: 73
Reputation: 3449
The line theUrl = 'testpage.php?id=' + id + '&hoeveelheid=' + document.getElementById("hoeveelheid_textfield").value;
has something which is null and is causing problems. Check whether id
or document.getElementById("hoeveelheid_textfield")
is null. Probably the latter is null and when you try to access the value
property the code breaks.
Upvotes: 3