Copy link to clipboard
Copied
I'm having a problem doing Jquery AJAX calls to a cffunction. Apparently html is being added to the return. I can't figure out where it happens and how to stop it. The site uses application.cfm and index.cfm to start a request.
Vaughn
Copy link to clipboard
Copied
Right.
And on the basis of that level of information, what are you expecting anyone to say? You're not even asking a question, as far as I can tell.
What do you mean "apparently html is being added"? Is it, or isn't it? I presume it is. What HTML is it?
Is it a case that you have CF debugging enabled, so all that bumpf is being added to the end of each response?
What have you done by way of troubleshooting?
I recommend you read this:
http://catb.org/esr/faqs/smart-questions.html
--
Adam
Copy link to clipboard
Copied
The Jquery code;
if ($(e.target).is(":checked")) {
$firstTD = $(this).parent().siblings().first()
alert($firstTD.text());
$.ajax({
type: "GET",
url: "cfc/basic.cfc?method=CheckDupeGroup&returnformat=json",
data: "dupegrouptocheck" + $firstTD.text(),
dataType: "json",
error: function (xhr, textStatus, errorThrown) {
// show error
alert(errorThrown);
},
success: function (response, textStatus, jqXHR) {
alert(response);
}
});
}
<cfoutput query="getinfo">
<td class="dupegroup">#dupe_group_number#</td>
<td><input type="checkbox" name="UserIDList" value="#userid#" /></td>
<td><a href="#request.controlURL#individuals/?fa=viewIndiv&cfgridkey=#userid#" style="color:##0000FF" target="_blank">#userid#</td>
<td>#lastname#</td>
<td>#firstname#</td>
<td>#nickname#</td>
<cfif qCheckClient>
<td style="background-color:orange;">#companyname#</td>
<cfelse>
<td>#companyname#</td>
</cfif>
<td>#address1#</td>
<td>#zipcode#</td>
<td>#state#</td>
<td><cfif qCheckCandidate>Candidate<cfelse> </cfif></td>
<td align="center">
<cfif qPages.not_dupe_flag>
<input class="notdupe" type="checkbox" name="indivID" value="#userid#" checked />
<cfelse>
<input class="notdupe" type="checkbox" name="indivID" value="#userid#" />
</cfif>
</td>
Copy link to clipboard
Copied
I'm doing a Jquery ajax call to a cfc cfunction. It should return a query. Using Firebug, I can see the returnded data and it appears to be wddx html wrapped around the query results. This causes an error on the ajax call. It depends on how I make the call. If I try to return Json, I get parsing errors of white space errors. If I try to return plain or text I get an error about no conversion done.
I've researched this and found (Ray Camden) that this type of html in the cfc reesponse breaks the call and needs to be stopped. However, all of that pertains to application.cfc and onRequestEnd.
<wddxPacket version='1.0'><header/><data><string></string></data></wddxPacket><!-- " ---></TD></TD><
/TD></TH></TH></TH></TR></TR></TR></TABLE></TABLE></TABLE></A></ABBREV></ACRONYM></ADDRESS></APPLET>
</AU></B></BANNER></BIG></BLINK></BLOCKQUOTE></BQ></CAPTION></CENTER></CITE></CODE></COMMENT></DEL><
/DFN></DIR></DIV></DL></EM></FIG></FN></FONT></FORM></FRAME></FRAMESET></H1></H2></H3></H4></H5></H6
></HEAD></I></INS></KBD></LISTING></MAP></MARQUEE></MENU></MULTICOL></NOBR></NOFRAMES></NOSCRIPT></NOTE
></OL></P></PARAM></PERSON></PLAINTEXT></PRE></Q></S></SAMP></SCRIPT></SELECT></SMALL></STRIKE></STRONG
></SUB></SUP></TABLE></TD></TEXTAREA></TH></TITLE></TR></TT></U></UL></VAR></WBR></XMP>
<font face="arial"></font>
<html>
<head>
<title>Error Occurred While Processing Request</title>
<script language="JavaScript">
function showHide(targetName) {
if( document.getElementById ) { // NS6+
target = document.getElementById(targetName);
} else if( document.all ) { // IE4+
target = document.all[targetName];
}
if( target ) {
if( target.style.display == "none" ) {
target.style.display = "inline";
} else {
target.style.display = "none";
}
}
}
</script>
</head>
<body>
<font style="COLOR: black; FONT: 16pt/18pt verdana">
The web site you are accessing has experienced an unexpected error.<br>
Please contact the website administrator.
</font>
<br><br>
<table border="1" cellpadding="3" bordercolor="#000808" bgcolor="#e7e7e7">
<tr>
<td bgcolor="#000066">
<font style="COLOR: white; FONT: 11pt/13pt verdana" color="white">
The following information is meant for the website developer for debugging purposes.
</font>
</td>
<tr>
<tr>
<td bgcolor="#4646EE">
<font style="COLOR: white; FONT: 11pt/13pt verdana" color="white">
Error Occurred While Processing Request
</font>
</td>
</tr>
<tr>
<td>
<font style="COLOR: black; FONT: 8pt/11pt verdana">
<table width="500" cellpadding="0" cellspacing="0" border="0">
<tr>
<td id="tableProps2" align="left" valign="middle" width="500">
<h1 id="textSection1" style="COLOR: black; FONT: 13pt/15pt verdana">
Unable to add text to HTML HEAD tag.
</h1>
</td>
</tr>
Copy link to clipboard
Copied
larksys wrote:
I'm having a problem doing Jquery AJAX calls to a cffunction. Apparently html is being added to the return. I can't figure out where it happens and how to stop it. The site uses application.cfm and index.cfm to start a request.
Here are some suggestions. Try them one at a time.
1) To rule out the application file as the cause, create a new Application.cfm which is empty except for:
<cfapplication name="cf_ajax_test"
sessionmanagement="Yes"
setclientcookies="Yes"
sessiontimeout="#createTimeSpan(0,0,20,0)#"
applicationtimeout="#createTimeSpan(1,0,0,0)#">
Put it in your cfc directory. Ensure that there is no other Application.cfm in the cfc directory itself or in any of its subdirectories. If there is, deactivate it by temporarily renaming it _Application.cfm.
2) Temporarily disable any cfflush tags to see what the effect is. Cfflush is known to cause ColdFusion to be "Unable to add text to HTML HEAD tag" .
3) The line url: "cfc/basic.cfc?method=CheckDupeGroup&returnformat=json" seems crowded and the line data: "dupegrouptocheck" + $firstTD.text() doesn't quite look right. You could perhaps rewrite them as follows:
url: "cfc/basic.cfc",
dataType: "json",
data: {
method: CheckDupeGroup,
returnformat: "json",
dupegrouptocheck: $firstTD.text()
}