Anti-Sina Weibo comment function implementation

Source: Internet
Author: User
The anti-Sina Weibo comment function is now in urgent need. It is the data implementation of anti-Sina Weibo comments. In ajax, click "comment" and send an ID to get all the response data, which is then displayed below. How can this be achieved? I also want to share it with him. Will it be displayed immediately after a comment? Implemented through AJAX ., You all know that the upload ID was implemented using ajax in the past, and it won't be written yet. the upload anti-Sina Weibo comment function is implemented.
Now, I have such a requirement. It is the data implementation of anti-Sina Weibo comments. Ajax implementation
Click "comment" and send an ID to get all the response data. The data is displayed below. How can this be achieved?
I also want to share it with him. Will it be displayed immediately after a comment?
Implemented through AJAX.
------ Solution --------------------
You all know that the upload ID is implemented using ajax in the past, so it won't be written.
------ Solution --------------------
After passing the code, ajax returns json js and reads js to present the data to the browser.
------ Solution --------------------
$ ("# RESUME_WORK_save"). bind ("click", function () {// for example, if the trigger condition is RESUME_WORK_save, you can also send ajax request call data based on the height of the scroll bar.
Var work_data = "data = jsondate &..."; // post data submission
$. Ajax ({
Type: "POST ",
Url: "xxx. php", // page to be submitted
Data: work_data,
BeforeSend: function (){
$ (This). attr ("disabled", true). val ("request ");
},
Success: function (data ){
Var jsonresult = JSON. parse (data); // You can assemble the retrieved data into a div, insert the div, or place it in the div container in any other processing method. For example, for the container of id worklist, you can see various insert methods in the jquery help document.
Var divbox = "xxx ";
/*
Internal insert
Append (content
------ Solution --------------------
Fn)
AppendTo (content)
Prepend (content
------ Solution --------------------
Fn)
PrependTo (content)
External insert
After (content
------ Solution --------------------
Fn)
Before (content
------ Solution --------------------
Fn)
InsertAfter (content)
InsertBefore (content)
*/
$ ("# Worklist"). after (divbox); // Insert divbox after worklist to achieve dynamic loading.
}
});
});

------ Solution --------------------
LZ is the implementation of the basic code.
There are also two methods for LZ to display the comment list.
One is to directly splice the html of the comment list on the server side to output the comment list.
The other is to return only the json data of the related comments on the server side, obtain or parse the json concatenated html on the client side, and then catch up with the html you need.
------ Solution --------------------
This function has been completed once. In fact, PHP returns JSON and inserts the HTML code append appendTo with jquery. However, you must control the append appendTo during loading. do not cause repeated loading on the client.
------ Solution --------------------
You need to convert the data to JSON first. the code is as follows:

var dt = '{"data":[{"commentid":"1","weiboid":"47","uid":"100001","content":"34535","datetime":"1350355452","syncid":"0","synctype":"0","replayuid":"0","replaycid":"0"},{"commentid":"2","weiboid":"47","uid":"100000","content":"34535","datetime":"1350355456","syncid":"0","synctype":"0","replayuid":"0","replaycid":"0"},{"commentid":"3","weiboid":"47","uid":"10016","content":"34535","datetime":"1350355471","syncid":"0","synctype":"0","replayuid":"0","replaycid":"0"},{"commentid":"37","weiboid":"47","uid":"100000","content":"656321","datetime":"1350355517","syncid":"0","synctype":"0","replayuid":"0","replaycid":"0"}],"total_rows":4}';
var json = eval('(' + dt + ')'); 
$(json.data).each(function(i, item){
alert(item.commentid)
})


------ Solution --------------------
Reference:
{"Data": [{"commentid": "231", "weiboid": "292", "uid": "10000", "content ": "KSLDFJSKL; FKJSL", "datetime": "1350355517", "syncid": "0", "synctype": "0", "replayuid": "0 ", "replaycid": "0"}], "total_rows ......

Jq has the json method. you can study it. this is very basic.
------ Solution --------------------
The problem has been solved for you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.