php - Undefined Index in Post request -
i have no thought why getting weird error!
php notice: undefined index: refid in /var/www/echo.php on line 5
i getting console output, cant echo refid. have done wrong here?
<?php $rollurl = 34; $refid = $_post['refid']; echo $refid; ?> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $.ajax({ url:'echo.php', type: 'post', data: { 'refid': "<?php echo $rollurl ?>" }, success: function(response){ console.log('getting response'); } }); </script>
please see comments in code below:
<?php $rollurl = 34; //only seek process post if there posted *and* refid exists if (count($_post) > 0 && isset($_post['refid'])) { $refid = $_post['refid']; echo $refid; //exit after echoing out refid html below not returned. exit(); } ?> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script> $.ajax({ url:'echo.php', type: 'post', data: { 'refid': "<?php echo $rollurl ?>" }, success: function(response) { //updated log show actual response received. console.log('getting response of "' + response + '"'); } }); </script> that works me when tested without errors beingness thrown , ajax beingness executed.
php jquery ajax undefined-index
No comments:
Post a Comment