I have a div to hold article content and it could be changed with ajax.
I need the content in this div and I use jquery function html() to do that, but it can only fetch the content before changing.
How can I get the immediate content using jquery?
Update:
It runs well in my own page and the problem comes with ‘share it to facebook’ button script from other sites.
This is an example script:
<script type="text/javascript" charset="utf-8">
(function(){
var _w = 72 , _h = 16;
var param = {
url:'dachaocai.com/bench/2',
type:'3',
count:'1',
appkey:'',
title:$('#title').html()+'(Bench->'+$('#b_name').html()+')'+'http://www.dachaocai.com/bench/2',
pic:'',
ralateUid:'',
rnd:new Date().valueOf()
}
var temp = [];
for( var p in param ){
temp.push(p + '=' + encodeURIComponent( param[p] || '' ) )
}
document.write('<iframe allowTransparency="true" frameborder="0" scrolling="no" src="http://hits.sinajs.cn/A1/weiboshare.html?' + temp.join('&') + '" width="'+ _w+'" height="'+_h+'"></iframe>')
})()
</script>
I use html() to get the article title to share but it’s always the old one.
Any way to solve this?
You can use Jquery to do an asynchronous call to a server then in the callback you can append some Html to a div. I hope this helps. If you post some code I can update the answer.
EDIT:
Create a div to put the result in:
In this way you can get the html from the server without having the complication of an iframe.
Then you can read the data from the div