<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>群英汇博客 &#187; AJAX</title> <atom:link href="http://blog.ossxp.com/category/%e6%8a%80%e6%9c%af%e6%96%87%e7%ab%a0/ajax/feed/" rel="self" type="application/rss+xml" /><link>http://blog.ossxp.com</link> <description></description> <lastBuildDate>Wed, 14 Sep 2011 03:52:03 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>jQuery 跨域 AJAX</title><link>http://blog.ossxp.com/2010/02/493/</link> <comments>http://blog.ossxp.com/2010/02/493/#comments</comments> <pubDate>Sun, 07 Feb 2010 07:53:34 +0000</pubDate> <dc:creator>蒋 鑫</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[jQuery]]></category><guid
isPermaLink="false">http://blog.ossxp.com/?p=493</guid> <description><![CDATA[jQuery 的跨域调用实际上没有那么复杂，只要明白几个概念，有一定的 JavaScript 基础即可。
首先要了解 jQuery.getJSON 函数
jQuery.getJSON( url, [data], [callback] )
===============================================
[1] As of jQuery 1.2, you can load JSON data located on another domain if you specify a JSONP callback.[2] The callback takes the form "example.com?callback=?". [3] jQuery automatically replaces the '?' with a random method name that doesn't clash with the global scope. You do not have <a
href="http://blog.ossxp.com/2010/02/493/" class="more-link">阅读全部内容 &#187;</a>]]></description> <wfw:commentRss>http://blog.ossxp.com/2010/02/493/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>jquery和php整合实例</title><link>http://blog.ossxp.com/2010/02/462/</link> <comments>http://blog.ossxp.com/2010/02/462/#comments</comments> <pubDate>Thu, 04 Feb 2010 11:55:12 +0000</pubDate> <dc:creator>雷 魏魏</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[php]]></category><guid
isPermaLink="false">http://blog.ossxp.com/?p=462</guid> <description><![CDATA[研究Jquery和php也有一段时间了，但是对两者深层次方面的整合还不是很精通。Google了N百次了，只能说收效甚微，一篇篇转烂了的JQuery和php整合的例子最后可能在你的机器上还是跑不起来，别泄气，这太正常了。我不能不感叹于那些高手们的懒惰，虽然我只能算的上菜鸟，请允许我发表一下自己的观点。本来我的这个小程序是不敢贴出来献丑的，但是鉴于这方面的资料确实太少，我还是贴出来吧。希望能给真正需要的人提供一些帮助。麻雀虽小，五脏俱全，也许你能从这个小程序中悟出来点什么。如果下面的例子不能理解，你可能需要补习一下理论基础，参见这个博客：jQuery跨域AJAX。
例子1：这个例子是JQuery和php不跨域的情况下整合的例子
首先我先叙述一下我的环境需要，以方便尝试跑这个小程序的朋友。你必须有一个wordpress 2.9系列，因为我这个程序中调用了Wordpress 2.9中的函数。在Wordpress根目录下建一个rpc文件夹，其他的也无所谓，自己看着改改相应的地方就行了。
下一步就把这两个文件copy到rpc下边就行了。其他的不需要任何改动，还有一点要提醒的，把jquery-1.4.js复制到rpc目录下
1、latest.php文件
&#60;?php
require_once("../wp-config.php");
//$arr = $_POST; //若以$.get()方式发送数据，则要改成$_GET.或者直接用:$_REQUEST
$arr = $_REQUEST['post_num'];
$show_post = "type=postbypost&#38;limit=6"; //该参数是传递给wp_get_archives函数的，wp_get_archives得到后会返回指定数目的日志
echo my_wp_get_archives($show_post);
function my_wp_get_archives($show_post)
{
return wp_get_archives($show_post);
}
?&#62;
2、latest.html文件
&#60;html&#62;
&#60;head&#62;
&#60;title&#62;演示&#60;/title&#62;
&#60;meta http-equiv="Content-Type" content="text/html; charset=utf8" /&#62;
&#60;/head&#62;
&#60;script language="javascript" src="jquery-1.4.js"&#62;&#60;/script&#62;
&#60;script language="javascript"&#62;
$(document).ready(function (){
$('#latest').click(function (){
var post_num=$('#number1').attr('value');
$.post('http://localhost/wordpress/rpc/latest.php?post_num='+post_num,show_post);
});
});function show_post(res){
//Replace contents of #result with retrieved result
$('#result').html(res);
}
&#60;/script&#62;&#60;body&#62;
&#60;div id="result" style="background:orange;border:1px solid red;width:300px;height:200px;"&#62;&#60;/div&#62;
&#60;form id="formtest" action="" method="post"&#62;
&#38;nbsp;&#38;nbsp;&#60;p&#62;&#60;span&#62;日志数:&#60;/span&#62;&#60;input type="text" name="number1" id="number1" size="15" &#62;&#60;/p&#62;
&#60;p&#62;&#60;span&#62;日志分类:&#60;/span&#62;&#60;input type="text" name="category" <a
href="http://blog.ossxp.com/2010/02/462/" class="more-link">阅读全部内容 &#187;</a>]]></description> <wfw:commentRss>http://blog.ossxp.com/2010/02/462/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (user agent is rejected)
Database Caching using disk

Served from: blog.ossxp.com @ 2012-02-11 05:46:08 -->
