I am creating a web page now.
here is the key components of the html
<span class='codeId' id='codeId1'>456</span>
<p class='codeDescription' id='description1'></p>
<span class='codeId' id='codeId1'>789</span>
<p class='codeDescription' id='description2'></p>
The codeIds
are obtained from database, so when page loaded, they will show up, however, the codeDescription
need to be obtained from webservices request call
from third party, basically you send the code
to their site and they will send response back.
I want to add responses to codeDescription
after the page loaded automatically.
If using a button, I can do a click
function for the p
tag, but can this be done by itself?
$('#btn').click(function(){
webserviceCall(code, callback(res){
$('p').text(res['description']);
});
})
as @mkaatman mentioned in his comment you can use document.ready...
$( document ).ready(function() {
webserviceCall(code, callback(res){
$('p').text(res['description']);
});
} );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.