Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 06, 2012 11:36 AM by mbhahn
Member
169 Points
119 Posts
Apr 05, 2012 07:03 PM|LINK
I am currently using .length to grab the number of css tweets and it gives me 20. Then i put the code at the oncomplete it says 2040
I need to remove the first 20 and keep the 40 so the account shows the accurate count of the page here is my code.
I was using append thats why it wasnt replacing. I cant seem to find the function i need
TThe counter 1 and counter 2 are the elements in the beginning and end of this code block.
should i remove the class onbegin and readd it oncomplete? whats the best practice?
$(document).ready(function () { var count = $('.TwitterMessageBox').length; $('#counter').append('The Count is ' + count); $('#loader').hide(); $("#StartLabel").click(function (e) { }) $.ajax({ headers: { 'X-Requested-With': 'XMLHttpRequest' }, // beforeSend: function () { $("#loaders").show(); }, // beforeSend:function () { $("#loaders").html("<img src="../../Content/ajax-loader.gif" alt="" /> Sending...").show();}, type: "Get", url: '/Home/Index', data: { 'X-Requested-With': 'XMLHttpRequest' }, // contentType: "application/text; charset=utf-8", dataType: "text", async: true, cache: false, success: function (data) { $('#TweetBox').prepend(data); $('#response').append('Load was performed.'); }, error: function (XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); }, beforeSend: function(){ $('#loader').show(); }, complete: function (resp){ alert(resp.getAllResponseHeaders()); $('#loader').hide(); //var counter = 2; var counter2 = $('.TwitterMessageBox').length; $('#counter').append(counter2); // $('#counter').find('#counter').text(counter2); } , }); }); });
229 Points
48 Posts
Apr 06, 2012 08:32 AM|LINK
If counter element is a form element (input), you can use .val( value )
else you can use .html( htmlString )
Apr 06, 2012 11:16 AM|LINK
no its just part of a label or span
Apr 06, 2012 11:22 AM|LINK
You can try this:
$("#counter").text($(".TwitterMessageBox").length); $("#counter").html($(".TwitterMessageBox").length);
Apr 06, 2012 11:36 AM|LINK
wow that worked!!
Thank you
mbhahn
Member
169 Points
119 Posts
Replacing the value on complete
Apr 05, 2012 07:03 PM|LINK
I am currently using .length to grab the number of css tweets and it gives me 20. Then i put the code at the oncomplete it says 2040
I need to remove the first 20 and keep the 40 so the account shows the accurate count of the page here is my code.
I was using append thats why it wasnt replacing. I cant seem to find the function i need
TThe counter 1 and counter 2 are the elements in the beginning and end of this code block.
should i remove the class onbegin and readd it oncomplete? whats the best practice?
Bieters
Member
229 Points
48 Posts
Re: Replacing the value on complete
Apr 06, 2012 08:32 AM|LINK
If counter element is a form element (input), you can use .val( value )
else you can use .html( htmlString )
mbhahn
Member
169 Points
119 Posts
Re: Replacing the value on complete
Apr 06, 2012 11:16 AM|LINK
no its just part of a label or span
Bieters
Member
229 Points
48 Posts
Re: Replacing the value on complete
Apr 06, 2012 11:22 AM|LINK
$("#counter").text($(".TwitterMessageBox").length); $("#counter").html($(".TwitterMessageBox").length);mbhahn
Member
169 Points
119 Posts
Re: Replacing the value on complete
Apr 06, 2012 11:36 AM|LINK
wow that worked!!
Thank you