<?php
$vote = $_REQUEST[‘vote‘];
//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);
//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];
if ($vote == 0)
{
$yes = $yes + 1;
}
if ($vote == 1)
{
$no = $no + 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclos...
实用小例:ajaxTest.html<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> jquery + ajax + php + select </title>
</head> <script type="text/javascript" src="http://code.jquery.com/jquery.mi...
(特感谢李南江老师提供视频教学)html结构:<div><p id="title">商品标题名称</p><img src="" alt=""><p id="des">商品描述信息</p><button name="nz">女装</button><button name="bb">包包</button><button name="tx">拖鞋</button></div>js:<script>window.onload = function (ev) {// 1.获取需要设置的元素var oTitle = document.querySelector("#title");var oDes = document.querySelector("#des");var oImg = document.querySe...
知识点:1、ajax删除;2、一个同步实现三个异步的效果。 html 部分 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head><title>招聘管理</title><link href="__PUBLIC__/HomeStyle/css/layout_903ac4c.css" rel="stylesheet" type="text/css" /><link href="__PUBLIC__/HomeStyle/css/widgets_68081...
http://www.yinghualuowu.com/php/echart.html创建table sex 有name num <?phpini_set(‘display_errors‘,1); //错误信息 ini_set(‘display_startup_errors‘,1); //php启动错误信息 error_reporting(-1); ini_set(‘error_log‘, dirname(__FILE__) . ‘/error3_log.txt‘);//打印出所有的 错误信息 require("config.php");$conn=mysqli_connect($mysql_server_name,$mysql_username,$mysql_passwo...
本篇将继续通过该实例讲解与数据库的交互方式。实例中用到的是MySQL,也可以根据自己的需要替换为其他数据库,其连接方式可以参考PHP相关手册。 在下面源程序包中dbconnector.php 提供了与MySQL的连接函数。 复制代码 代码如下:<?php //定义数据连接变量 define ("MYSQLHOST", "localhost"); define ("MYSQLUSER", "root"); define ("MYSQLPASS", "root"); define ("MYSQLDB", "test"); function opendatabase(){ //连接数据库所在...
XMLHttpRequest cannot load http://localhost:8080/abc/index.php. No ‘Access-Control-Allow-Origin‘ header is present on the requested resource. Origin ‘file:///E:/myprogram/php/abc/index.html‘ is therefore not allowed access. 我想实现的目标是这样的: 用php写好一个接口,然后html中ajax直接post这个接口,进行json数据的交互。我只要json,不要说什么jsonp。简化的index.html代码 1<!DOCTYPE html> 2<html> 3<...
function sousuo($page){var URL=‘‘;if($page){URL=‘__URL__/index/usercenter/selectorder?page=‘+$page;}else {URL=‘__URL__/index/usercenter/selectorder‘;}var ktime=$("#some_class_1").val();var eyime=$("#some_class_2").val();var content=$(".content");content.remove();$(‘.pagecss‘).empty();$(‘.va-m‘).remove();$.ajax({type: "post",data: {ktime:ktime,etime:eyime},url: URL,dataType: "json",succes...
前台页面:两种写法都可以:(1)// var ajaxurl = "{:U(‘Index/postDomain?ajax=1‘)}"; // 这样写也行 $.ajax({ // url: "/index.php/Home/Index/postDomain/ajax/1" , // 这样写也行 // url: ajaxurl , url: "{:U(‘Index/postDomain?ajax=1‘)}" , data: {‘url‘:url,‘contact‘:contact}, type: "get", dataT...
php程序是部署在IIS7上面,ajax提交数据时,遇到了两个问题,一个就是跨域,一个php程序总会被执行两次。第一个问题的解决方法,是百度出来的,添加下面几行代码就可以了:header(‘Access-Control-Allow-Origin:*‘);header("Access-Control-Allow-Headers: x-requested-with,content-type");header(‘Access-Control-Allow-Methods: OPTIONS,POST,GET‘);其实,也可以直接在iis里面设置,不用添加代码,直接选择站点,然后点右边...
很早就听闻ajax的名声,但是却一直不知道怎么用,今天自己捣鼓了一下,竟然会用了,哈哈哈哈。为了防止我自己忘记,现在把这个简单的实例记录下。这个实例是网上搜的,文末附上链接。首先你得有自己的服务器,这个我已经采用xampp配置好了。实现ajax需要三个文件,一个是html的表单文件,一个是js的核心文件,一个是php的后台文件。具体的文件如下所示:下面的是test.html文件,当键盘按下时触发showHint方法,在showHint方法中会有...
在Thinkphp目录的Lib\ORG\Util\目录里新建AjaxPage.class.php,写入一下内容:<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2009 http://thinkphp.cn All rights reserved.
// +-----------------------------------------------------------...
发现一个 thinkphp5 的小bug 我用的是 thinkphp5.0.24 版本 在模板标签里 原来的大U函数 被改成url 那么问题来了 在javascript里 这样写 标签很容易被替换掉就是上面这句 被浏览器解释出来就变成了这样 出错了 经反复研究 这样写就不会出错了 逗号换行分割开来 就可以了 哈 被我发现的 原文:https://www.cnblogs.com/trip-j/p/12048768.html
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式。易于人阅读和编写,同时也易于机器解析和生成。JSON在前后台交互的过程中发挥着相当出色的作用。服务端PHP读取MYSQL数据,并转换成JSON数据,传递给前端Javascript,并操作JSON数据。本文将通过实例演示了jQuery通过Ajax向PHP服务端发送请求并返回JSON数据。阅读本文的读者应该具备jQuery、Ajax、PHP相关知识,并能熟练运用。XHTML
<ul id="userlist"> <li><a href=...
网址:http://www.helloweba.com/view-blog-191.html源码下载地址:http://files.cnblogs.com/h07061108/php%E9%AA%8C%E8%AF%81%E7%A0%81.rar原文:http://www.cnblogs.com/h07061108/p/verification_code.html