Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cfajaxproxy Error 500 Content Is Not Allowed In Prolog

Posted on 2011-02-25
8
Medium Priority
?
880 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 668 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 664 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
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!

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

670 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