• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

jQuery, promise(), and done() - is it really?

LEGEND ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

Hello, all,

I have kind of a weird jQuery issue going on, and I'm not sure what to make of it.

The project that I'm working on (unfortunately, it's on a restricted site, so no one can access it) is a blog that allows comments and replies.

From the main page, if a blog has any comments, there is a link at the bottom of the blog that allows the user to view the comment.  Clicking the link will expand a hidden div that contains the comment.

If there is a reply to the comment, there is a text link ("More") that appears.  Clicking the "More" link will use AJaX to run a query on the database to get the reply.

I have it set up so that when the link is clicked, a small spinner gif will appear to let the user know that the system is working in the background to get the reply.  Once the database returns the data, the spinner disappears and is replaced by the content.

Here's the issue:  I'm using promise().done(function(){}); to make that happen, which is supposed to wait until the data is loaded before making the spinner disappear.  But the spinner is disappearing almost immediately, and the reply content is not appearing for at least 10 to 15 seconds.

It's as if the server is giving an immediate response of "Got it!  Here ya go," but the browser is taking its sweet time displaying the content.

Any suggestions on either A) what's causing this, or B) how to get it to wait until the browser is ready to display the content before making the spinner disappear?

V/r,

^_^

Views

530

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

Its a bit hard to say without more code. You will really need to provide the whole block that does the job.

I would say you will be better off asking this questions on Stack Overflow.​ You will get a response pretty quick there for jQuery related issues, this is a Adobe Coldfusion forum after all.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

StackOverflow (and all related sites) are not so much a support forum as they are a popularity contest.  Questions are voted down just for the sake of voting down, without any real explanation as to why.  I had an SO account, once.  I deleted it four days later, after having stared in slack-jawed amazement at the stupid 5h|t people do, there.

I do realize that this is a CF forum; a lot of CF coders also work with JavaScript and either jQuery or MooTools.  And since this question involves using AJaX to run a .cfc function that queries a database and returns data, my question is not un-related.

V/r,

^_^

PS:  Let me get the code organized so I can provide some pseudocode samples of what I am doing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

You could also try posting on the CFML Slack team, where there is a dedicated #javascript channel.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

Thanks, Carl Von Stetten​,

I completely forgot about the Slack team.  I did receive an invitation, a long time ago, and just never got around to actually going there.  I've been so focused on other things.  Thank you for the reminder.  I'll see if I can find that invitation email, and hope that it isn't blocked by the network, here.


V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

That would be a huge "no" from work.  Blocking the proxy, so I cannot access it from work.  Dangit. 

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

I sent up a flare on Slack for you.  We'll see if someone responds back here.

-Carl V.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

Thank you, again, Carl.  I really appreciate it.  I'm going to see if I can convince the network powers-that-be to allow slack.com through the proxy.  I doubt I'll convince them, but wish me luck. 

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

I was looking at the code, getting ready to post some of it, here, and I now think that I'm going about this the wrong way.

I'm going to see if I can set it so that when the "More" link is clicked, it will be replaced by the spinning gif image, then it will submit the data request and replace the image with the returned data.  I think.  At least, it won't rely upon trying to add a callback to a function that doesn't natively have a callback.  I might have over-complicated things.  

I'll report back.

Thank you,

^_^

PS.  I am using promise() to do what I originally had in mind; I just now read that IE has ZERO support for promise().. so.. yeah.. no choice, since IE is a required browser for many internal systems, and many do not have FireFox installed.  SMH.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

You can check out this fiddle here: AJAX Test - JSFiddle

From reading your post I think this is what you are looking for,but I may be wrong, at a minimum it should point you in the right direction. If not let me know.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 23, 2016 Jun 23, 2016

Copy link to clipboard

Copied

LATEST

Thanks, averagejoe77​,

That is the process I am trying to achieve, thank you.

But, thanks to some others who have been making changes to files for the same project, but on other servers, the rest of today has been declared 'a wash'.  The SA and DBA are currently trying to synchronize everything, which will take all night, so I can't make any changes until tomorrow.    I'll give your suggestion a shot, tomorrow, and report back.

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation