php,jQuery,Lightbox,Ajax GET和POST问题

编程入门 行业动态 更新时间:2024-10-09 21:18:02
本文介绍了php,jQuery,Lightbox,Ajax GET和POST问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一张表格(fancybox)。 我想要做一个ajax来运行数据库的更新。 但我不知道为什么它不起作用。 下面的代码是什么在灯箱:

I have a form in a lightbox (fancybox). I am trying to do an ajax get to run an update to the database. But I do not know why it does not work. The code below is what is in the lightbox:

<div id="timezonelightbox"> <div class="lightboxtitle">Select Time Zone</div> <form method="get" action="" > <select name="timezones" id="timezones" class="selecttimezones"> <option value="Africa/Abidjan ">Africa/Abidjan </option> <option value="Africa/Accra ">Africa/Accra </option> <option value="Africa/Addis_Ababa ">Africa/Addis_Ababa </option> <option value="Africa/Algiers ">Africa/Algiers </option> <option value="Africa/Asmara">Africa/Asmara</option> </select> <input type="button" id="confirmtimezone" class="confirmtimezone" value="Confirm now" onclick="updateTimeZone(); $.fancybox.close();"> </form> </div> <script type="text/javascript"> function updateTimeZone(){ $.getScript('<?echo $site["url"];?>/updateTimeZone.php?timezones=<?echo $_GET["timezones"]?>'); } </script>

这就是我在被调用文件中的内容:

This is what I have in the called file:

header("content-type:text/js"); if(isset($_GET['timezones'])){ $queryupdatetimezone="UPDATE `Profiles` SET `TimeZone` ='".$_GET['timezones']."' WHERE ID=".(int)$_COOKIE['memberID']; $resultupdatetimezone=mysql_query($queryupdatetimezone) or die("Errore update default timezones: ".mysql_error()); exit; }else{ ?>alert ('An error occured');<? } ?>

当我点击确认按钮时,一切都很正常。没有错误。但是当我查看数据库时,它会保存一个空字符串。 $ _GET ['timezones']是空的。这怎么可能?我做错了什么?

Everything seems fine when I click the confirm button. No errors. But when I look in the database it saves an empty string. $_GET['timezones'] is empty. How is that possible? What am I doing wrong?

推荐答案

这是一个emtry字符串,因为您发送的是空字符串。看看你发布的这一行:

It's an emtry string, because you are sending an empty string. Look at this line you posted:

$.getScript('/updateTimeZone.php?timezones=');

你可能忘了给你想要的时区,像这样:

You probably forgot to give the timezone you wanted into there like this:

$.getScript('/updateTimeZone.php?timezones=THE_TIMEZONE');

用您想要的时区替换 THE_TIMEZONE 设置...

Replace THE_TIMEZONE with the timezone you want to set...

更多推荐

php,jQuery,Lightbox,Ajax GET和POST问题

本文发布于:2023-10-10 22:02:41,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:jQuery   php   Lightbox   POST   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!