JSON+XmlHttp实现Ajax

visibility 288 access_time 14 years ago language中文 timeline Stats
timeline Stats
Page index 0.06
more_horiz

在做一个ajax的实例中,自己选择的是用返回的字符串而不是xml来传递数据

现在如果改成JSON的话则要简单的多,因为在以前没有用到js中的eval的时候全部是采取分析字符串的方法去获得传输回来的内容。

引用别人的一个例子

//回调函数 简单回调函数
function showesay(dataResponse)
{
var data = eval('(' + dataResponse.responseText + ')');
var str='';
str+='<ul>';
str+='<li>'+data.param1;+'</li>';
str+='<li>'+data.param2;+'</li>';
str+='</ul>';
document.getElementById("content").innerHTML=str;
}


info Last modified by Raymond 14 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

expand_more
Table of contents
More from Kontext
JavaScript Convert SVG to Base64
visibility 447
thumb_up 1
access_time 7 months ago
Bootstrap 4 Mega Full Width Dropdown Menu
visibility 6,562
thumb_up 4
access_time 3 years ago
Bootstrap 4 Mega Full Width Dropdown Menu
Trigger Event after All Images Loaded
visibility 204
thumb_up 0
access_time 9 months ago