jQuery AJAX POST gives undefined index

Posted by Sebastian on Stack Overflow See other posts from Stack Overflow or by Sebastian
Published on 2012-09-16T09:35:26Z Indexed on 2012/09/16 9:37 UTC
Read the original article Hit count: 252

Filed under:
|
|
|
|

My eventinfo.php is giving the following output:

<br />
<b>Notice</b>:  Undefined index:  club in <b>/homepages/19/d361310357/htdocs/guestvibe/wp-content/themes/yasmin/guestvibe/eventinfo.php</b> on line <b>11</b><br />
[]

HTML (index.php):

<select name="club" class="dropdown" id="club">
<?php getClubs(); ?>
</select>

jQuery (index.php):

<script type="text/javascript">

    $(document).ready(function() {
        $.ajax({
            type: "POST",
            url: "http://www.guestvibe.com/wp-content/themes/yasmin/guestvibe/eventinfo.php",
            data:  $('#club').serialize(),
            success: function(data) {
                $('#rightbox_inside').html('<h2>' + $('#club').val() + '<span style="font-size: 14px"> (' + data[0].day + ')</h2><hr><p><b>Entry:</b> ' + data[0].entry + '</p><p><b>Queue jump:</b> ' + data[0].queuejump + '</p><br><p><i>Guestlist closes at ' + data[0].closing + '</i></p>');
                },
            dataType: "json"
        });
    });

    $('#club').change(function(event) {
        $.ajax({
            type: "POST",
            url: "http://www.guestvibe.com/wp-content/themes/yasmin/guestvibe/eventinfo.php",
            data:  $(this).serialize(),
            success: function(data) {
                $('#rightbox_inside').hide().html('<h2>' + $('#club').val() + '<span style="font-size: 14px"> (' + data[0].day + ')</h2><hr><p><b>Entry:</b> ' + data[0].entry + '</p><p><b>Queue jump:</b> ' + data[0].queuejump + '</p><br><p><i>Guestlist closes at ' + data[0].closing + '</i></p>').fadeIn('500');
                },
            dataType: "json"
        });

    });

</script>

I can run alerts from the jQuery, so it is active.

I've copied this as is from an old version of the website, but I've changed the file structure (through to move to WordPress) so I suspect the variables might not even be reaching eventinfo.php in the first place...

index.php is in wp-content/themes/cambridge and eventinfo.php is in wp-content/themes/yasmin/guestvibe but I've tried to avoid structuring issues by referencing the URL in full.

Any ideas?

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript