I'm trying to create a simple calendar utilizing my knowledge in PHP and MySQL, but I want to have it as instant as possible. I'm using an article and the plugin sourcerer. At first I created a simple input for Year-Month like so:

  <input type="month" id="dateCal" name="dateCal" value="{source}<?=date('Y-m')?>{/source}" onchange="func(this.value)">

My idea is to get that input and use it for all my following calculations in PHP, however, I need to get it first, I'm using the following code:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
function func(selectedValue) {
        url: 'index.php',
        type: 'POST',
        data: {valueYM: selectedValue},
        success: function() {
            console.log("Data sent!");
if ($_REQUEST['valueYM']) {
    $val = $_REQUEST['valueYM'];
    echo $val;

As far as I know, that should work, that should return the value that is in the input, however, it doesn't work, I get the console message but the PHP function is never called, the URL value is definitely wrong, I don't really know how to tweak it and I barely found any info in google, could you give me a hand?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.