Ajax send parameters php doesn't receive it

I'm trying to send parameters from AJAX to PHP but that is not happening and I don't know why. This is a simple code. All I want to do is to send parameter param to the same form and print the value to the page.

Source Code

PHP:

<?php

    if(isset($_GET))
    {
        echo $_GET["param"];
    }

?>

HTML:

<table>
    <tr>    
        <td><input type="text" id="myText" /></td>
        <td style="width:35px;"><div id='myDiv' style=" display:none;"><img src="30.gif" id="myImage" /></div></td>
        <td><input type="button" value="button" name="myButton" onClick="myFunction()"/></td>
    </tr>
</table>

JavaScript:

<script>
function myFunction(){
    document.getElementById('myDiv').style.display='inline';
    xmlHttp=new XMLHttpRequest();
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4 && xmlHttp.status==200)
        {
            setTimeout("callMe()",3000);    
        }

    }       
    xmlHttp.open("GET","myAjax.php?param=1",true);
    xmlHttp.send(); 
}

function callMe()
{
    document.getElementById('myText').value=xmlHttp.responseText;
    document.getElementById('myDiv').style.display='none';
}
</script>

Answers


Just try with:

if (isset($_GET['param'])) {
    echo $_GET['param'];
}

It works well when I have tested.


Need Your Help

Need to write to a file using fopen in a C++ class for iOS project

iphone c++ objective-c ios ffmpeg

I have a project that uses C++ classes and FFmpeg, I need to use fopen and write a file to the app sandbox, so the code that I need to write in C++ is the equivalent of:

SQLite boolean values in Lua

sqlite lua corona

I'm having some trouble finding an elegant solution to this. I'm creating an app using Corona that has a SQLite db. One of the columns in the db is a boolean. I know that SQLite uses 1 or 0 for tru...