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");

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...";
     }

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(){

Thanks it worked !!!

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.