1

I am trying to update mysql database on cliking url in lecture.php. But update-lecture-count.php is not getting executed.

Code in lecture.php is as follows

<?php
session_start();
include("db.php");
?>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" >    </script>
<script>
var $j = jQuery.noConflict();// i am also using jquery 1.9.0 in same page
$j('.reserve-button').click(function(){

var lec_id = $j(this).parent().data('id');

$j.ajax
({ 
    url: 'update-lecture-count.php',
    data: {"lectureID": lec_id},
    type: 'post'

});
});
</script>

</head>
<body>

<div data-id="<?php echo $data['lecture_id'];?>">
/* lecture id, recording link are getting fetched from other mysql table*/
<a class="reserve-button fancybox fancybox.iframe more_info_btn" data-fancybox-href="<?=$data['recording_link']?>">PLAY NOW</a>
</div>
</body>
</html>

Code in update-lecture-count.php is as follows

<?
session_start();
include("db.php");
if(isset($_POST['lectureID']))
  {
$_SESSION['value'] = $_POST['lectureID'];
$member_id = $_SESSION['user_id'];

//code to update mysql database.....
?>

I am unable to understand, why $_POST['lecture_id'] is not retrived in update-lecture-count.php

2 Answers 2

1

Try replacing type with 'method' - type is used in versions prior to Jquery 1.9.0

So try to use this as your AJAX call

$j.ajax
({ 
    url: 'update-lecture-count.php',
    data: {"lectureID": lec_id},
    method: 'post'

});

Please refer to this link

Sign up to request clarification or add additional context in comments.

Comments

0

Ohhh... I solved it... Just answering here as it would be helpful to others too...

I replace

<script>
var $j = jQuery.noConflict();

$j('.reserve-button').click(function(){

var lec_id = $j(this).parent().data('id');

$j.ajax
({ 
    url: 'update-lecture-count.php',
    data: {"lectureID": lec_id},
    method: 'post'

});
});
</script>

To

<script>
var $j = jQuery.noConflict();
$j(document).ready(function() {
$j('.reserve-button').click(function(){

var lec_id = $j(this).parent().data('id');

$j.ajax
({ 
    url: 'update-lecture-count.php',
    data: {"lectureID": lec_id},
    method: 'post'

});
});
});
</script>

And it worked ...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.