ECSHOP实现AJAX传值方式
以下示例文件flower.php为测试的php页面,相应的模板文件为flower.dwt
在flower.dwt页面写入
<!DOCTYPE html>
<html>
<head>
<meta charset=”utf-8″ />
<title>测试的</title>
{insert_scripts files=’transport.js’}
<script type=”text/javascript”>
function textaaa()
{
if(document.getElementById(‘test’)){
var rec_id=document.getElementById(‘test’).value;
Ajax.call(‘flower.php?act=ajax’, ‘rec_id=’ + rec_id, textres, ‘GET’,’JSON’);
}
}
function textres(result){
alert(result.content);
}
</script>
</head>
<body>
<input type=”text” id=”test” />
<input type=”button” οnclick=”textaaa()”/>
</body>
</html>
相应的flower.php页面写入
define(‘IN_ECTOUCH’, true);
require(dirname(__FILE__) . ‘/include/init.php’);
require(ROOT_PATH . ‘include/lib_order.php’);
require_once(ROOT_PATH .’include/cls_json.php’);
if ($_REQUEST[‘act’] == ‘ajax’)
{
$keywords = json_str_iconv(trim($_GET[‘rec_id’]));
$keywords= $keywords+1;
$json = new JSON;
$result = array(‘error’ => 0, ‘message’ => ”, ‘content’ => $keywords);
die($json->encode($result));
}
$smarty->display(‘flower.dwt’);
php运行
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
7. 本站有不少源码未能详细测试(解密),不能分辨部分源码是病毒还是误报,所以没有进行任何修改,大家使用前请进行甄别!
66源码网 » ECSHOP实现AJAX传值方式