Skip to main content
December 14, 2012
Answered

retrieving Ajax callback

  • December 14, 2012
  • 1 reply
  • 660 views

I just wrote my first Ajax code, and am looking for a more elegant way to retrieve the callback from the ColdFusion server page.  My callback page returns this data:  <html><body><div>6</div></body></html>  Right now I am using this Javascript to retrieve the 6 from inside the div:  (data = string sent by server page) var divloc = data.indexOf('div'); var callback = data.substr(divloc+4,1);  Is there a better way to retrieve the 6 from those HTML tags, or could I get the server page to pass just the 6, without the HTML, back to the calling page?

This topic has been closed for replies.
Correct answer

Solved this one myself; data = $(data).text();  seems to put the callback data into a form reliably usable by the rest of my functions.

1 reply

Correct answer
December 15, 2012

Solved this one myself; data = $(data).text();  seems to put the callback data into a form reliably usable by the rest of my functions.

BKBK
Community Expert
Community Expert
December 15, 2012

Good for you. Please kindly mark the solution.