ben bu kod jQuery / php var:
$(document).ready(function() {
$("#editorForm").submit(function(){
alert('json');
var dataString = $("#editor1").val();
var id=1;
$.post('/DataTransfer/EditContent.php?id='.id, { data: dataString}, function(res){
alert(res);
var obj = jQuery.parseJSON(res);
$("#dataContainer").html(obj.data);
$("#ckContainer").hide('slow');
$("#dataContainer").show('slow');
$("#modifica").html('Modifica');
}, "text");
return false;
});
});
Böyle bir sunucu tarafı EditContent.php:
<?php
include_once("../Classes/HtmlHelpers.php");
include_once("../Classes/DbHelpers.class.php");
$link=dbHelpers::OpenConnection();
$pageId=$_GET["id"];
$data= $_REQUEST['data'];
$sql = "UPDATE `ghionet2_Common`.`Pages` SET `PA_INNER_HTML` = '$data' WHERE `Pages`.`PA_ID` = $pageId;";
$result=mysql_query($sql, $link)or die("errore: ".mysql_error());
$retdata= array( 'sql'=>$sql,'id'=>$pageId, 'data'=>$data);
dbHelpers::CloseConnection($link);
echo $_GET['callback'] .json_encode($retdata);
?>
Ne oldu? neden $ gibi tüm arama sayfası html dönmek retdata:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"/>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="description" content="Home Page"/>
<meta name="keywords" content=""/>
<title>Home</title>
<link rel="stylesheet" href="/Content/Site.css" type="text/css"/>
<link rel="stylesheet" href="/Scripts/jQuery/fancybox/jquery.fancybox-1.3.4.css" type="text/css"/>
<script type="text/javascript" src="/Scripts/jQuery/jquery-1.4.4.min.js">
</script>
<script type="text/javascript" src="/Scripts/Index.js">
</script>
</head>
<body>
<div id="banner">
<script type="text/javascript" src="http://free.netsons.com/free728x90.php?i=341463"></script>
</div>
<div id="header">
<div id="memberInfo">
<strong> Benvenuto admin!</strong> | <a class="iframe" href="ChangePassword.php">Cambia Password</a> | <a href="LogOut.php">Esci</a></div>
</div>
<div id="menu">
</div>
<div id="main">
<div id="content">
<div id="dataContainer">
<p>
...