|
 |
|
ปรึกษาการส่งค่า จาก ajax ที่ return กลับมา เข้า function jquery |
|
 |
|
|
 |
 |
|
code ajax ครับ
<script type="text/javascript">
$(document).ready(function() {
$("#in_time").change(function(){
var intime = $(this).val();
$.post("result.php",{ p_intime: intime},
function(data) {
$('#stage').html(data);
});
});
});
</script>
ส่ง ไปที่ result.php มีการ return ค่ากลับมา
<?php
$time = $_POST['p_intime']*1000;
?>
<script type="text/javascript">
$(document).ready(function() {
var intime = <?php echo $time?>;
alert(intime);
});
</script>
แล้วจะนำ ค่า intime มาใช้ใน function นี้ยังไงครับ
<!-- stage-->
<div id='stage'>
<script type="text/javascript">
var intime;
$(document).ready(function() {
$('#features').wowBook({
height : 650
,width : 900
,centeredWhenClosed : true
,hardcovers : true
,slideShowDelay: intime
,turnPageDuration :1500
,numberedPages : ['page',-2]
,controls : {
zoomIn : '#zoomin',
zoomOut : '#zoomout',
next : '#next',
back : '#back',
first : '#first',
last : '#last',
slideShow : '#slideshow',
flipSound : '#flipsound'
}
}).css({'display':'none', 'margin':'auto'}).fadeIn(1000);
});
</script>
</div>
<!-- stage-->
ขอบคุณครับ
Tag : PHP, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2014-07-24 18:41:02 |
By :
yemenamen |
View :
1584 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
result.php
Code (PHP)
<?php
$time = $_POST['p_intime']*1000;
?>
ฝั่งแสดงผล
Code (PHP)
<script type="text/javascript">
var intime;
$(document).ready(function() {
$('#features').wowBook({
height : 650
,width : 900
,centeredWhenClosed : true
,hardcovers : true
,slideShowDelay: intime
,turnPageDuration :1500
,numberedPages : ['page',-2]
,controls : {
zoomIn : '#zoomin',
zoomOut : '#zoomout',
next : '#next',
back : '#back',
first : '#first',
last : '#last',
slideShow : '#slideshow',
flipSound : '#flipsound'
}
}).css({'display':'none', 'margin':'auto'}).fadeIn(1000);
});
</script>
<div id='stage'></div>
|
 |
 |
 |
 |
Date :
2014-07-24 19:08:45 |
By :
fossil31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รวม jQuery ในที่เดียวกันเลย
Code (PHP)
$(document).ready(function() {
intime=500;
$("#in_time").change(function(){
var intime = $(this).val();
$.post("result.php",{ p_intime: intime},function(data) {
//$('#stage').html(data);
$('#features').wowBook({
height : 650,
width : 900,
centeredWhenClosed : true,
hardcovers : true,
slideShowDelay: data,
turnPageDuration :1500,
numberedPages : ['page',-2],
controls : {
zoomIn : '#zoomin',
zoomOut : '#zoomout',
next : '#next',
back : '#back',
first : '#first',
last : '#last',
slideShow : '#slideshow',
flipSound : '#flipsound'
}
}).css({'display':'none', 'margin':'auto'}).fadeIn(1000);
});
});
$('#features').wowBook({
height : 650
,width : 900
,centeredWhenClosed : true
,hardcovers : true
,slideShowDelay: intime
,turnPageDuration :1500
,numberedPages : ['page',-2]
,controls : {
zoomIn : '#zoomin',
zoomOut : '#zoomout',
next : '#next',
back : '#back',
first : '#first',
last : '#last',
slideShow : '#slideshow',
flipSound : '#flipsound'
}
}).css({'display':'none', 'margin':'auto'}).fadeIn(1000);
});//document
|
 |
 |
 |
 |
Date :
2014-07-24 19:15:09 |
By :
fossil31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำไม ไม่คำนวณที่ jQuery เลย เพราะส่งไปก็ไม่ได้เรียก Database เลย
Code (PHP)
$(document).ready(function() {
intime=500;
$("#in_time").change(function(){
intime = parseInt($(this).val()) * 1000;
$('#features').wowBook({
height : 650,
width : 900,
centeredWhenClosed : true,
hardcovers : true,
slideShowDelay: intime,
turnPageDuration :1500,
numberedPages : ['page',-2],
controls : {
zoomIn : '#zoomin',
zoomOut : '#zoomout',
next : '#next',
back : '#back',
first : '#first',
last : '#last',
slideShow : '#slideshow',
flipSound : '#flipsound'
}
}).css({'display':'none', 'margin':'auto'}).fadeIn(1000);
});
$('#features').wowBook({
height : 650
,width : 900
,centeredWhenClosed : true
,hardcovers : true
,slideShowDelay: intime
,turnPageDuration :1500
,numberedPages : ['page',-2]
,controls : {
zoomIn : '#zoomin',
zoomOut : '#zoomout',
next : '#next',
back : '#back',
first : '#first',
last : '#last',
slideShow : '#slideshow',
flipSound : '#flipsound'
}
}).css({'display':'none', 'margin':'auto'}).fadeIn(1000);
});//document
|
 |
 |
 |
 |
Date :
2014-07-24 19:20:21 |
By :
fossil31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ ได้ครับ
ลอง แล้วค่า intime มันก็ ยังไม่เปลี่ยน
|
 |
 |
 |
 |
Date :
2014-07-25 10:44:33 |
By :
yemenamen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|