脚本宝典收集整理的这篇文章主要介绍了如何在PHP中使用jQuery变量,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的脚本中,我有变量“direccion”,这是我需要使用PHP传递给控制器,但我不知道如何实现这一点.
脚本代码(查看):
jquery(document).ready(function () { VAR direccion=""; var flag = false; jQuery(".validation").change(function () { flag = true; jQuery(".validation").each(function () { if (jQuery(this).val().trim() == "") { alert("false"); flag = false; } }); if (flag==true) { var calle = jQuery("#ff_elem295").val(); var municipio = jQuery("#id_municipio option:selected").text(); var PRovincia = jQuery("#id_provincia option:selected").text(); direccion = calle +","+ municipio +","+ provincia; direccion = direccion.replace(/\s/g,'+'); //alert(direccion); } }); jQuery.ajax({ url: "index.PHP?option=com_cstudomus&controller=saloninmobiliarios&task=calcularDistancias",data : direccion,dataTyPE : 'htML' }).done(function(){ var data = data; }); });
function calcularDistancias(){ $valor = JRequest::getVar('direccion'); $url = 'http://maps.googleapis.COM/maps/api/geocode/json?address='. $valor .'&sensor=false'; $data = file_get_contents($url); $data_array = json_decode($data,true); $lat = $data_array[results][0][geometry][location][lat]; $lng = $data_array[results][0][geometry][location][lng]; ...... }
以上是脚本宝典为你收集整理的如何在PHP中使用jQuery变量全部内容,希望文章能够帮你解决如何在PHP中使用jQuery变量所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。