8 Replies Latest reply on Mar 16, 2016 1:20 PM by Carl Von Stetten

    jquery ajax get works but 500 error is thrown

    AkosF Level 1

      Hi guys, I have this issue where I'm using Jquery to get a simple string from a cfc and although the string is returned correctly I also get a bunch of unwanted HTML code appended to the response. The HTML  code is CF's 500 error page.
      It does not happen if I comment out the ajax call but as soon as I put it back it happens.  It's driving me nuts.  There are no errors listed in the logs.  The original application was not written by me and it uses application.cfm and onrequestend.cfm, I've commented out all code in onrequestend.cfm in case that's what's causing it but no change.   I've attached screenshots of the alert pop up where you can see that the response is there at the top.
      Been browsing for a solution but cannot find it. Not sure where to start debugging it.  It must be something soo simple that I overlook. Any help would be much appreciated.
      Here's my simple JS:

       

      var thisEmail = $('#emailAddress').val();

       

      $.ajax({

        type: "get",

        url:"cfcs/subscribe.cfc?returnformat=plain&email="+thisEmail,

        data: { method: "doSubscribe" },

        cache:false,

        normalizeJSON: true,

        success: function(data) {

       

        alert(data);

       

        });

       

      Here's my simple CFC function:

       

      <cffunction name="doSubscribe" access="remote" returntype="any" returnFormat="plain" output="no">

         

        <cfargument name="email" type="string" required="yes">

            

        <cfreturn "test response">

              

         

        </cffunction>

       

       

      Capture.PNGCapture2.PNG