Tag: php

单击按钮时更新div,单击另一个按钮生成按钮时

单击按钮magic1或magic2 ,div mybox将更新为文本,按钮ID和按钮( magic1和magic2不同)。 单击新生成的按钮后,它应显示box div中新生成按钮的按钮ID。 当我单击新生成的按钮时, box div不会更新。 这是代码。 jquerycode.php是初始文件。 单击magic1或magic2按钮,Ajax将调用session.php页面。 jquerycode.php文件 My jQuery Ajax test #mybox { width: 300px; height: 250px; border: 1px solid #999; } #box { width: 300px; height: 250px; border: 1px solid #999; position: absolute; right:210px; } $(document).ready(function(){ $(“.magic_button”).click(function() { var data = $(this).attr(‘id’); //alert (data); $.ajax({ type: “POST”, url: […]

jquery自动完成与php文件查询mysql数据库

我正在尝试使用带有mysql数据库的jquery自动完成文本输入来获取自动完成建议。 从教程我得到了以下用于查询数据库的php函数。 <?php include "db_connect.php"; $search = protect($_GET['term']); $result = mysql_query("SELECT planeID FROM `planes` WHERE `planeID` LIKE '%$search%' ") or die('Something went wrong'); $json = '['; $first = true; while ($row = mysql_fetch_assoc($result)) { if (!$first) { $json .= ','; } else { $first = false; } $json .= '{"value":"'.$row['planeID'].'"}'; } $json .= ']'; echo […]

为每个用户刷新聊天正文

我一直在尝试使用php + ajax + mysql创建一个聊天系统。 Live Table Data Edit You Are : $(document).ready(function() { function fetch_data() { $.ajax({ url: “select.php”, method: “POST”, success: function(data) { $(‘#live_data’).html(data); } }); } fetch_data(); $(document).on(‘click’, ‘.first_name’, function() { var id = $(this).data(“id1”); function fetch_chat() { $.ajax({ url: “fetch_chat.php”, method: “POST”, data: { id: id }, dataType: “text”, success: function(data) […]

当我从PHP回应它时,jQuery无法正常工作

我只需要在PHP脚本的某些部分运行一些js,为了测试目的,我注释掉了php,所以我不会在这里显示它。 <?php echo ' var width = $(window).width();<—Not working down too 1A var height = $(window).height(); var widthSTR = width.toString(); widthSTR = widthSTR.concat("px"); var heightSTR = height.toString(); heightSTR = heightSTR.concat("px"); heightSTR = " ".concat(heightSTR); var size = widthSTR.concat(heightSTR); $("body").css({ "background-size" : size, <—1A and above ^ "background" : "url(p.jpg) 50% 0 no-repeat fixed"<—1B }); ‘; […]

如何在等待用户输入的同时暂停jQuery .each()循环?

在继续迭代之前,我无法获得jQuery .each loop来等待用户输入。 这是我的代码(我评论过我想要发生的事情): query(“SELECT movies_dir FROM settings”); $row = $query->fetch(PDO::FETCH_ASSOC); date_default_timezone_set(‘UTC’); echo “Movie Scanner”; ?> var retval = “not done”; function EnterManually() { alert(“Entering Data Manually”); //data has been entered manually so exit function & move ontop next index in loop in document.ready. retval = “done”; } function insertIntoDB(id,path) { var request = $.ajax({ […]

在不使用数据库的情况下以JSON格式从服务器获取响应?

我是服务器端编程的新手,我需要一个form和操作,当用户填写名称,地址和密码时,提交从那时起页面应该加载(如本机提交)和新数据应该显示(数据)在JSON文件中可用)。 我在服务器上有JSON文件。 是否可以在不使用数据库的情况下以JSON格式从服务器获取响应? HTML:— JSON:— json.json位于https://domain.com/jsonfilelocation/json.json { “name”: “kk”, “address”: “XYZ, New Delhi”, “pincode”: “1000001” }

如何在PHP脚本中访问从jQuery.ajax()的HTML页面传递的表单数据的各个值?

我将表单数据传递给PHP脚本以通过JS( jQuery.ajax() )进行处理。 问题是 – 我无法找到一种方法来访问PHP中的单个表单控件值(例如$_POST[‘zipcode’] )。 相反,我只能使用$_POST[‘form’]访问数据,这是一个表示为一个长字符串的整个表单(例如string(89)”color=red&color=blue&zipcode=12345…” )。 如何通过JS访问从HTML表单传递的PHP脚本中的表单数据的各个值? 的index.php(forms)的 Red Green Blue 的index.php(JS) $(‘#myform’).on(‘submit’, function(e) { e.preventDefault(); $.ajax({ type: ‘POST’, dataType: ‘html’, url : ‘PHPscript.php’, data: {form : $(‘#myform’).serialize()} }).done(function(data) { var myJSONresult = data; alert(myJSONresult); }); }); PHPscript 编辑: 邮政编码字段: $(“#zipcode”).focus(function(){ if(this.value == “zipcode”){ $(this).val(“”); } }).blur(function(){ if(this.value == “”){ $(this).val(“zipcode”); } […]

AJAX Pagination添加了替换数据的数据

我有一个有效的基于PHP的分页,我正在添加ajax以改善页面加载。 我的问题是ajax正在添加整个导航页面 (通过分页链接进行导航)到当前页面内容 。 并且要添加的特定数据是用于内容显示的div中的整个导航页面。 这应该像用 导航页面内容替换当前页面内容一样。 我的分页在div中, id =“pagination”和ul li。 我的重复页面内容在div中, id =“temp” 。 我的ajax代码 $(function(){ $(‘#pagination ul li a’).click(function (ev) { ev.preventDefault(); $(‘div#temp’).load($(this).attr(‘href’)); }); }); 我的导航链接结构就是这样的 echo ” Next»» “; 请告诉我如何使用ajax替换添加数据的数据。 谢谢。

jQuery AJAX调用数据库查询

我有一个AJAX函数: function admin_check_fn(type) { //$(“#notice_div”).show(); //var allform = $(‘form#all’).serialize(); $.ajax({ type: “POST”, //async: false, url: “/profile/adminquery_check.php”, data: { type: type }, //data: ‘code=’+code+’&userid=’+userid, dataType: “json”, //dataType: “html”, success: function(result){ var allresult = result.res $(‘#result’).html( allresult ); alert(allresult); //$(“#notice_div”).hide(); } }) } 和服务器端: $queryy=”SELECT * FROM wp_users”; $name = array(); $resultt=mysql_query($queryy) or die(mysql_error()); ?> array($rowss[‘display_name’]), “fvdfvv” […]

如何在jQuery中将PHP变量传递给Datepicker?

我试图在datepicker中设置一个默认日期,我将一个变量传递给PHP中的html。 这是我的控制文件和表单的简化版本: 控制文件: $default_date]); ?> 这是表格: jQuery UI Datepicker – Default functionality $(function() { $(“#mydate”).datepicker ({ onSelect: function(dateText, inst) { var dateAsString = dateText; var date = $(‘#mydate’).val(); } }) //.datepicker(“setDate”,new Date()); .datepicker(“setDate”,new Date(2014,10-1,17)); }); Date: 如果我使用setDate的注释行,我会得到当前日期。 如果我使用我的线路,我会在7天前收到日期。 当我在表单的顶部打印$ default_date时,我得到了2014,10-1,17,但我无法确定将其传递到脚本中。 其他人建议使用