0

can anyone help me with this error?

INVALID_STATE_ERR: DOM Exception 11

on this line

hr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
2
Contributors
4
Replies
19
Views
4 Years
Discussion Span
Last Post by gon1387
0

to make it clearer thisis the ajax code

function show_details(theId){
    var deets=(theId.id);
    el=document.getElementById("overlay");
    el.style.display=(el.style.display=="block")? "none":"block";
    el=document.getElementById("events");
    el.style.display=(el.style.display=="block")? "none":"block";
    var hr= new XMLHttpRequest();
    var url="events.php";
    var vars="deets="+deets;
    hr.open=("POST",url,true);
    hr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    hr.onreadystatechange=function(){
    if (hr.readyState==4 && hr.status==200)
        {var return_data=hr.responseText;
        document.getElementById("events").innerHTML = return_data;
        }
}
    hr.send(vars);
     document.getElementById("events").innerHTML = "po procesohet...";
     }
0

That problem typically occurs when you use setRequestHeader before open. To make it short, you have a typo at line 10, on your posted code:

    var vars="deets="+deets;
    //change this to this
    // hr.open("POST",url,true);
    hr.open=("POST",url,true);
    hr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    hr.onreadystatechange=function(){

This should be the correct snippet:

    var vars="deets="+deets;
    hr.open("POST",url,true);
    hr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    hr.onreadystatechange=function(){

Edited by gon1387

0

Yes it is. My mistake. I forgot to indicate that there was a '=' in the midle of open and the open parenthesis (

// With the '=' typo
hr.open=("POST",url,true);
// Without the '='
hr.open("POST",url,true);

Edited by gon1387

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.