Solved

Cfajaxproxy Error 500 Content Is Not Allowed In Prolog

Posted on 2011-02-25
8
865 Views
Last Modified: 2012-08-14
I would like to run some asyncrynous code by pushing a button on a coldfusion 8 page.
I have a coldfusion component that creates a string and returns it.
When I do cfinvoke it works perfect but I can not seem to run the same code via cfajaxproxy.
I get the error "Contnet is Not Allowed In Prolog".
How can I fix this issue?

--------------------

<cfoutput>
<cfajaxproxy cfc="#REQUEST.cfcPath#\mycfc" jsclassname="jobj" />
</cfoutput>
<html>
<head>
    <script type="text/javascript">
            function serverTimeClick()
            {
                  var instance = new jobj();
                  instance.setCallbackHandler(displayResponse)  
            instance.setErrorHandler(errorHandler)
                  instance.serverTime();
            }
            function displayResponse(resp)
        {
            document.getElementById("output").innerHTML = resp
        }
        function errorHandler(statusCode,statusMsg)
        {
            alert(statusCode+': '+statusMsg)
        }
            
    </script>
</head>
<body>

            <cfoutput>#REQUEST.cfcPath#</cfoutput><br /><br />
            <button name="serverTime" onClick="serverTimeClick()">Server Time</button>
            <br><br>
            <br><br>
            <div id="output"></div>

<!--- // this works just fine //
<cfinvoke component="#REQUEST.cfcPath#\mycfc" method="serverTime" returnvariable="mylocal" />
<cfoutput>#mylocal#</cfoutput>
--->
</body>
</html>

---------------

<cfcomponent  name="mycfc" >

      <cffunction name="init" returntype="void" hint="Initializes variables" access="public" output="false">
            <!--- Place initialization code here --->
      </cffunction>
   
      <!--- Gets the server date and time --->
       <cffunction name="serverTime" access="remote" returntype="string">
            <cfset var mylocal = "this is my string" />        
           <cfreturn mylocal />
       </cffunction>

</cfcomponent>
0
Comment
Question by:FastEddie___
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 167 total points
ID: 34981142

Watch out for extra spaces in the values you're passing, use trim() around them according to this article

http://www.bennadel.com/blog/1206-Content-Is-Not-Allowed-In-Prolog-ColdFusion-XML-And-The-Byte-Order-Mark-BOM-.htm
0
 

Author Comment

by:FastEddie___
ID: 34981309
That's good advice but it did not help.
I trimmed the var on the cfc before returning it.
It's just so strange that cfinvoke would work just fine but not via cfajaxproxy.
Any other thoughts?


0
 
LVL 36

Assisted Solution

by:SidFishes
SidFishes earned 166 total points
ID: 34981390
if you were using firebug you would see the returned ajax result

My guess is the content not allowed error is due to an error page being returned.

looks like you are trying to access the function but have the incorrect access type public

for any type of ajax call you need access="remote"

public is for "public: available to a locally executing page or component method."

0
 
LVL 36

Expert Comment

by:SidFishes
ID: 34981415
sorry ignore that

i saw the init function access = public

(although the firebug advice still holds)
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 11

Accepted Solution

by:
Brijesh Chauhan earned 167 total points
ID: 34981450
>> Content is not allowed in prolog is an error generally emitted by the Java XML parsers when data is encountered before the <?xml... declaration. You may inspect the document in a text editor and think nothing is wrong, but you need to go down to the byte level to understand the problem. You probably have a character encoding bug.

http://illegalargumentexception.blogspot.com/2010/09/java-content-is-not-allowed-in-prolog.html
0
 

Author Comment

by:FastEddie___
ID: 34981459
right... It should have been remote.
I changed it but still got the same error.
I'll try firebug to see what's going on.
0
 

Author Comment

by:FastEddie___
ID: 34984705
Looking at it in firebug it looks like it freaks out when going form the CF package to the apache.xerces.jaxpSAXParserImpl package.

Here is the error:

      at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
      at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
      at coldfusion.wddx.DeserializerWorker.deserialize(DeserializerWorker.java:268)
      at coldfusion.wddx.WddxDeserializer.deserialize(WddxDeserializer.java:96)

It looks like thats when "Unknown Source" starts poping up.

I really have no idea what that means but it has to do with the xml parser.

I'll post this and come back to split points.

I don't know how else to attack this problem.

0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 34985840
Here is something related in CF Bug database

http://www.elliottsprehn.com/cfbugs/bugs/83819#steps-to-reproduce
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now