php传递数据给jquery,将值从php传递给jquery
我需要一些幫助,我想知道如何將一個值從PHP變量傳遞給jquery腳本?
我正在做的是打開一個模式窗口,從mysql瀏覽器創建的元素列表中,所以我需要傳遞一個變量值的錨點。
這是我的代碼:
$query_tours = "Select * from tours where feautured = 'Y' " ;
$result_tours = mysql_query($query_tours);
while($row=mysql_fetch_array($result_tours )) {
$tourID = $row['recid'];
$tit_esp = $row['tit_esp'];
$adrate = $row['ad_rate'];
$chrate = $row['ch_rate'];
echo '
';print "$tit_esp
";
print "Adultos : $adrate | Ni?os : $chrate ";
print "ver detalles";
print "
";}?>
這里是jquery腳本:
$(function() {
$( "#dialog:ui-dialog" ).dialog( "destroy" );
var adult = $( "#adult" ),
child = $( "#chl" ),
fecha = $("#datepicker"),
allFields = $( [] ).add( adult ).add( child ).add( fecha ),
tips = $( ".validateTips" );
function updateTips( t ) {
tips
.text( t )
.addClass( "ui-state-highlight" );
setTimeout(function() {
tips.removeClass( "ui-state-highlight", 1500 );
}, 500 );
}
function checkLength( o, n, min, max ) {
if ( o.val()> max || o.val()< min ) {
o.addClass( "ui-state-error" );
updateTips( "El numero de " + n + " debes ser entre " +
min + " y " + max + "." );
return false;
} else {
return true;
}
}
function checkFecha() {
var dfecha = document.getElementById('datepicker').value;
if(dfecha == ""){
//dfecha.addClass( "ui-state-error" );
updateTips( "Fecha Incorrecta");
return false;
}else{
return true;
}
}
function checkRegexp( o, regexp, n ) {
if ( !( regexp.test( o.val() ) ) ) {
o.addClass( "ui-state-error" );
updateTips( n );
return false;
} else {
return true;
}
}
$( "#dialog-form" ).dialog({
position: 'center',
autoOpen: false,
draggable: true,
height: 300,
width: 410,
modal: true,
show : {
transitionIn: 'blind',
transitionOut: 'explode',
},
open: function(event, ui) {
$( "#datepicker" ).datepicker('enable');
alert(regis)
$.ajax({
url: 'tour_cont.php',
data: "regis=" + regis + "",
dataType: 'json',
success: function(data){
var titulo = data[1];
var user = data[3];
var comenta = data[4];
$( "#dialog-form" ).append( "
" +"
" + titulo + "" + "" );}
});
},
buttons: {
"Agregar al Carrito": function() {
var bValid = true;
bValid = bValid && checkFecha( datepicker );
bValid = bValid && checkLength( adult, "adultos", 1, 10 );
bValid = bValid && checkLength( child, "ni?os", 0, 10 );
if ( bValid ) {
$( "#users tbody" ).append( "
" +"
" + adult.val() + "" +"
" + child.val() + "" +"
" + fecha.val() + "" +"
" );$( this ).dialog( "close" );
}
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
$('#datepicker').datepicker('disable');
}
});
$('a[class^=myTour]')
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
});
$( "#create-chichen" )
.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
});
});
希望有人能夠低估我,先進的謝謝!
總結
以上是生活随笔為你收集整理的php传递数据给jquery,将值从php传递给jquery的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++学习之路 | PTA(天梯赛)——
- 下一篇: h5 换脸 php,【部分原创】pyt