Solved

Cfajaxproxy Error 500 Content Is Not Allowed In Prolog

Posted on 2011-02-25
8
874 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___
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

Question has a verified solution.

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

Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
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 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)
Suggested Courses

623 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