Solved

Cfajaxproxy Error 500 Content Is Not Allowed In Prolog

Posted on 2011-02-25
8
867 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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
 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

770 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