来自chinaz的ajax获取评论代码_javascript技巧
ajax获取到的字符是类似下面的内容
然后用下面的ajax进行输出
var key='';
var str=new Array();
function createAjaxObj(){
var httprequest=false
//document.domain='chinaz.com';
if (window.XMLHttpRequest){ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml');
}
else if (window.ActiveXObject){ // if IE
try
{
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return httprequest;
}
function load_feedback(arcID,pg){
/*
var url = "http://www.chinaz.com/plus/feedback_ajax.php?action=show&arcID="+arcID+"&pg="+pg;
var ajax = new oAjax();
// 是否显示错误
//ajax.error = true;
// 请求的页面的编码为'gb2312'或空
//ajax.encode = 'gb2312';
// 回调函数
ajax.callback = function (content) {
// 处理返回内容
eval('var obj = ' + content);
document.getElementById('fedbk').innerHTML=obj.a;
document.getElementById('fedcount').innerHTML=obj.b;
};
ajax.send(url);
*/
var xmlhttp = createAjaxObj();
try
{
var params="action=show&arcID="+arcID+"&pg="+pg;
xmlhttp.abort();
xmlhttp.open("get","/plus/feedback_ajax.php?"+params,true);
xmlhttp.setRequestHeader("Content-type", "text/html;charset=gb2312");
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange=f
xmlhttp.send(null);
}catch(ex){}
function f()
{
if(xmlhttp.readyState!= 4 || xmlhttp.status!=200 )
return ;
var b= xmlhttp.responseText;
var obj = eval("("+b+")");
document.getElementById('fedbk').innerHTML=obj.a;
document.getElementById('fedcount').innerHTML=obj.b;
document.getElementById('feedcounttop').innerHTML=obj.b;
}
}
function load_allfeedback(arcID,pg){
var xmlhttp = createAjaxObj();
try
{
var params="action=showall&arcID="+arcID+"&pg="+pg;
xmlhttp.abort();
xmlhttp.open("get","/plus/feedback_ajax.php?"+params,true);
xmlhttp.setRequestHeader("Content-type", "text/html;charset=gb2312");
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange=f
xmlhttp.send(null);
}catch(ex){}
function f()
{
if(xmlhttp.readyState!= 4 || xmlhttp.status!=200 )
return ;
var content= xmlhttp.responseText;
var obj = eval("("+content+")");
// eval('var obj = ' + content);
document.getElementById('fedbk').innerHTML=obj.a;
//document.getElementById('fedcount').innerHTML=obj.b;
}
}
function feed_back(){
var msg = trim(document.getElementById('msg').value);
var arcID = document.getElementById('arcID').value;
var username = trim(document.getElementById('username').value);
var pwd = trim(document.getElementById('pwd').value);
var checkbox = document.getElementById('notuser');
if(checkbox.checked)
var notuser = 1;
else
var notuser = 0;
var xmlhttp = createAjaxObj();
try
{
params="action=send&arcID="+arcID+"&msg="+msg+"&username="+username
+"&pwd="+pwd+"¬user="+notuser;
xmlhttp.abort();
xmlhttp.open("get","/plus/feedback_ajax.php?"+params,true);
xmlhttp.setRequestHeader("Content-type", "text/html;charset=gb2312");
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange=f
xmlhttp.send(null);
}catch(ex){}
function f()
{
if(xmlhttp.readyState!= 4 || xmlhttp.status!=200 )
return ;
var arr = xmlhttp.responseText.split("@:");
if(!arr[1]){
alert(xmlhttp.responseText);
}
else{
if(arr[0] != 'true')
alert(arr[0]);
alert(arr[2]);
ck_yzimg();
load_feedback(arr[1],1);
}
}
}
function goodbad(fid,arcid,actname,pg){
var xmlhttp = createAjaxObj();
try
{
params = "action="+actname+"&fid="+fid+"&arcID="+arcid+"&pg="+pg;
xmlhttp.abort();
xmlhttp.open("get","/plus/feedback_ajax.php?"+params,true);
xmlhttp.setRequestHeader("Content-type", "text/html;charset=gb2312");
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange=f
xmlhttp.send(null);
}catch(ex){}
function f()
{
if(xmlhttp.readyState!= 4 || xmlhttp.status!=200 )
return ;
var arr = xmlhttp.responseText.split("@:");
if(!arr[1])
alert(xmlhttp.responseText);
else{
alert(arr[0]);
load_feedback(arr[1],arr[2]);
}
}
}
function goodbad2(fid,arcid,actname,pg){
var xmlhttp = createAjaxObj();
try
{
params = "action="+actname+"&fid="+fid+"&arcID="+arcid+"&pg="+pg;
xmlhttp.abort();
xmlhttp.open("get","/plus/feedback_ajax.php?"+params,true);
xmlhttp.setRequestHeader("Content-type", "text/html;charset=gb2312");
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.setRequestHeader("Content-length", params.length);
xmlhttp.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange=f
xmlhttp.send(null);
}catch(ex){}
function f()
{
if(xmlhttp.readyState!= 4 || xmlhttp.status!=200 )
return ;
var arr = xmlhttp.responseText.split("@:");
if(!arr[1])
alert(xmlhttp.responseText);
else{
alert(arr[0]);
load_allfeedback(arr[1],arr[2]);
}
}
}
function pg(vl){
var arcID = document.getElementById('arcID').value;
load_feedback(arcID,vl);
}
function pg2(arcID,vl){
//var arcID = document.getElementById('arcID').value;
load_allfeedback(arcID,vl);
}
function ck_yzimg(){
//document.all.cknum.value='';
document.all.msg.value='';
document.all.username.value='';
document.all.pwd.value='';
document.getElementsByName('sb')[0].disabled = false;
//document.all.img1.onclick();
}
function trim(s) {
return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}
//////
/*
String.prototype.Contains = function(str) {
return (this.indexOf(str) > -1);
};
var Browser = {
s : navigator.userAgent.toLowerCase()
};
(function (b) {
b.IsIE = b.s.Contains('msie');
b.IsIE5 = b.s.Contains('msie 5');
b.IsIE6 = b.s.Contains('msie 6');
b.IsIE7 = b.s.Contains('msie 7');
b.IsIE56 = !b.IsIE7 && (b.IsIE6 || b.IsIE5);
b.IsGecko = b.s.Contains('gecko');
b.IsSafari = b.s.Contains('safari');
b.IsOpera = b.s.Contains('opera');
b.IsMac = b.s.Contains('macintosh');
b.IsIELike = (b.IsIE || b.IsOpera);
b.IsGeckoLike = (b.IsGecko || b.IsSafari);
}) (Browser);
function oAjax () {
this.req = null;
this.url = '';
this.content = '';
this.type = 'text';
this.encode = '';
this.asyn = true;
this.action = 'get';
this.error = false;
}
oAjax.prototype.init = function () {
if (window.XMLHttpRequest) {
this.req = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// isIE = true;
try {
this.req = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e) {
try {
this.req = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
this.req = false;
}
}
}
var self = this;
if (this.req) {
this.req.onreadystatechange = function () {self.listener()};
}
};
oAjax.prototype.listener = function () {
if (this.req.readyState == 4) {
if (this.req.status == 200) {
// right
try {
this.callback(Browser.IsIE && this.encode == 'gb2312' ? oAjax.gb2utf8(this.req.responseBody) : (this.type == 'text' ? this.req.responseText : this.req.responseXML));
}
catch (e) {
this.halt('[callback] ' + e.name + ':' + e.message);
}
}
else {
// error
this.halt('[callback error] ' + this.req.status);
}
}
};
oAjax.prototype.send = function (url) {
this.init();
url = this.url = url || this.url || '';
this.content = !!this.content ? this.content : '';
this.encode = this.encode ? this.encode.toLowerCase() : '';
this.asyn = this.asyn == undefined ? true : !!this.asyn;
this.action = (this.action == undefined || this.action == 'get') ? 'Get' : 'Post';
this.error = this.error == undefined ? false : !!this.error;
if (! url && this.error) {
alert('Ajax请求URL不能为空。');
return;
}
try {
this.req.open(this.action, url, this.asyn);
}
catch (e) {
this.halt('[open] ' + e.name + ':' + e.message);
return;
}
try {
this.req.setRequestHeader('Connection', 'close');
this.req.setRequestHeader('Accept-Encoding', 'gzip, deflate');
this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded' + (this.encode ? ';charset=' + this.encode : ''));
if(this.req.overrideMimeType && this.encode) {
this.req.overrideMimeType('text/xml' + (this.encode ? ';charset=' + this.encode : ''));
}
this.req.send(this.content);
}
catch (e) {
this.halt('[open] ' + e.name + ':' + e.message + '\n** 检查是否为跨域访问。');
}
};
oAjax.prototype.callback = function (content) {
//alert(content);
};
// abort
oAjax.prototype.abort = function () {
this.req.abort();
};
oAjax.prototype.halt = function (description) {
this.error && alert(description);
};
// gb2312 to utf8
oAjax.gb2utf8 = function (data) {
var glbEncode = [];
gb2utf8_data = data;
execScript("gb2utf8_data = MidB(gb2utf8_data, 1)", "VBScript");
var t = escape(gb2utf8_data).replace(/%u/g,"").replace(/(.{2})(.{2})/g,"%$2%$1").replace(/%([A-Z].)%(.{2})/g,"@$1$2");
t = t.split("@");
var i=0, j = t.length, k;
while(++i k = t[i].substring(0,4);
if(!glbEncode[k]) {
gb2utf8_char = eval("0x" + k);
execScript("gb2utf8_char = Chr(gb2utf8_char)", "VBScript");
glbEncode[k] = escape(gb2utf8_char).substring(1, 6);
}
t[i] = glbEncode[k] + t[i].substring(4);
}
gb2utf8_data = gb2utf8_char = null;
return unescape(t.join("%"));
}
*/
核心代码
var b= xmlhttp.responseText;
var obj = eval("("+b+")");
document.getElementById('fedbk').innerHTML=obj.a;
document.getElementById('fedcount').innerHTML=obj.b;
document.getElementById('feedcounttop').innerHTML=obj.b;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

As a popular social e-commerce platform, Xiaohongshu’s user comments are an important interactive link. Many users find that on Xiaohongshu, the latest comments often appear at the bottom of the comment area. Why is this? This article will delve into the sorting mechanism of Xiaohongshu’s comment area and share some tips for ranking comments at the front. 1. Why are the latest comments on Xiaohongshu at the bottom? The default sorting method of the Xiaohongshu comment area is to display comments in chronological order, that is, the latest comments will be displayed at the bottom of the comment area. This sorting method helps users easily view the latest comments and obtain real-time information. Xiaohongshu encourages interaction between users and encourages users to actively participate in comments by placing the latest comments at the bottom of the page. This design allows users to browse other users’ comments,

People enjoy posting videos, browsing videos, commenting and interacting on Douyin. But in the comment interaction, sometimes we may make some inappropriate remarks or make mistakes and want to delete these comments. So how to delete my own comments on Douyin? 1. How to delete my comments on Douyin? 1. Log in to Douyin App and find the video with the comment you want to delete. 2. At the bottom of the video page, find a list of all comments. 3. Find your comment, click the heart icon (like) on the right side of the comment, then click the delete icon (trash can) to confirm deletion. 4. If you @ other people in the comment, you will receive a prompt when deleting the comment: "After deleting this comment, the person @ will not receive the notification." If you want the person @ to receive the notification, you can Cancel @ first,

Xiaohongshu is a popular social e-commerce platform where users can share shopping tips, recommend products and exchange shopping experiences. Some users found that comments they posted on Xiaohongshu were always displayed at the bottom, which confused them. This article will explore why Xiaohongshu’s comments arrangement causes user comments to appear at the bottom, and introduce how to modify the position of comments on Xiaohongshu. 1. Why are Xiaohongshu’s own comments at the bottom? The display order of comments on Xiaohongshu is usually based on the chronological order of the comments. If your comment is posted after another user has commented, it will appear at the bottom. This is Xiaohongshu’s default comment sorting method, which is designed to maintain order and clarity in the comment area. Xiaohongshu may based on the content of the comments

Xiaohongshu is a popular social media platform where users can share their lives and exchange experiences. Some users will find that when they comment on other people's posts, they cannot see it. So, why can’t others see my comments on Xiaohongshu? This article will explore this issue in detail to help you resolve your confusion. 1. Why can’t others see my comments on Xiaohongshu? Delayed review: Xiaohongshu review content has been reviewed and may be temporarily hidden due to containing sensitive words or illegal content. In this case, the other party may not be able to see the comment temporarily after it is posted. Generally, these comments will reappear once moderation is complete. Account anomalies may cause comments posted by commenters not to be seen by the other party, even if the comments are successfully posted. Such abnormal situations include accounts being banned or functions limited.

Xiaohongshu is a popular social e-commerce platform where users can share their shopping experiences and recommend products. Some users reported that they were troubled by the fact that the images they uploaded in their comments were not displayed properly. This article will help you find out why images in Xiaohongshu comments cannot be displayed and provide solutions. 1. Why can’t pictures be displayed in Xiaohongshu comments? Image formats may not be supported: Xiaohongshu’s comment function only supports limited image formats. If the image format you upload is not supported, the image may not be displayed. It is recommended that you try other formats, such as JPG, PNG, etc. The size of images uploaded in comments may be limited by Xiaohongshu. If the size of your image is too large, it may not be displayed properly. It is recommended that you try pressing

Xiaohongshu is a content-rich and interactive social platform where users can post and comment on various contents. Sometimes we may encounter situations where our comments are deleted by bloggers. So, will the blogger be reminded if a Xiaohongshu comment is deleted? What should we do if it is deleted? 1. Will the blogger be reminded if a Xiaohongshu comment is deleted? After a Xiaohongshu comment is deleted by the blogger, the system will provide a notification to the user. Users can check the notification in Xiaohongshu’s message center to learn why their comments were deleted. Users can also find their deleted comments in the comment record on their personal homepage and view the relevant situation. 2. What should I do if my comments in Xiaohongshu are deleted? 1. Stay calm: First of all, we need to stay calm and don’t panic or get angry. Bo

Google Authenticator is a tool used to protect the security of user accounts, and its key is important information used to generate dynamic verification codes. If you forget the key of Google Authenticator and can only verify it through the security code, then the editor of this website will bring you a detailed introduction on where to get the Google security code. I hope it can help you. If you want to know more Users please continue reading below! First open the phone settings and enter the settings page. Scroll down the page and find Google. Go to the Google page and click on Google Account. Enter the account page and click View under the verification code. Enter your password or use your fingerprint to verify your identity. Obtain a Google security code and use the security code to verify your Google identity.

In the current digital age, Xiaohongshu has become the main platform for many people to share their lives and obtain information. Sometimes, we may need to delete historical comments on Xiaohongshu, or encounter a situation where the comments are successful but cannot be seen. This article will focus on these two issues, providing detailed operation methods and possible causes. 1. How to delete historical comments on Xiaohongshu? To delete historical comments on Xiaohongshu, you can usually follow the following steps: 1. Find the comments: In the Xiaohongshu APP, find the comments you posted. Comments usually appear below the note or in the comments section. 2. Long press on a comment: Use your finger to long press on your comment until the delete option appears. 3. Confirm deletion: In the pop-up deletion confirmation dialog box, click the "OK" or "Delete" button to delete
