意见箱
恒创运营部门将仔细参阅您的意见和建议,必要时将通过预留邮箱与您保持联络。感谢您的支持!
意见/建议
提交建议

php+jquery+ajax+json实现跨域调用phppdo操作oracle数据库

来源:恒创科技 编辑:恒创科技编辑部
2024-01-09 06:46:59
<?php
/*
* Created on 2012-7-4
*
* write by harry
*
*/ echo
'<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
* { margin:0; padding:0;}
body { font-size:12px;}
.comment { margin-top:10px; padding:10px; border:1px solid #ccc;background:#DDD;}
.comment h6 { font-weight:700; font-size:14px;}
.para { margin-top:5px; text-indent:2em;background:#DDD;}
</style>
<!-- 引入jQuery -->
<script src="../scripts/jquery-1.3.1.js" type="text/javascript"></script></head>
<body>
<br/>
<p>
<input type="button" id="send" value="加载"/>
</p>
<script> $(function() { $.getJSON(\'http://127.0.0.1/test.php?callback=?\',{no:"123456789",name:"ecshop"},function(json){ alert(json.key); }); }); </script>
<div class="comment">已有评论:</div>
<div id="resText" > </div>
</body>
</html>';
?>
____________________________________<?php
$dbh = new PDO('oci:dbname=ecshop, 'root,'root');
$no=$_GET['no'];
$name=$_GET['name'];
if($no&&$name)
{ $results = array("key" => "$name");

echo $_GET['callback'] . '(' . json_encode($results) . ')';
$stmt = $dbh->prepare("insert into EMP(emp,name ) VALUES (:no, :name)");
$stmt->bindParam(':no', $no, PDO::PARAM_STR, 30); $stmt->bindParam(':name', $name, PDO::PARAM_STR, 30);




$stmt->execute();
}
/*
$callback = isset($_GET["callback"]) ? $_GET["callback"]:"callback";
$getstr = isset($_GET["ajaxstr1"]) ? $_GET["ajaxstr1"] : "";
$data = array('type'=>1);
echo $_GET['callback'].'('.json_encode($data).')';
exit;
*/?>


php+jquery+ajax+json实现跨域调用phppdo操作oracle数据库

上一篇: GridView、Repeater等数据控件列数字、货币和日期的显示格式 . 下一篇: phpoci8.dll插入数据到oracle数据库php操作oracle数据库亲测ORA-00911无效字符错误解决方法