Solved

Cfajaxproxy Error 500 Content Is Not Allowed In Prolog

Posted on 2011-02-25
8
873 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

734 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