>> GreenByte.info By Nick Tong (quiksilv) | Supported by: TalkWebSolutions.co.uk

AJAX - Length Required issue with POST

I've been having an issue in Firefox using AJAX where I've been getting this error/response

<h1>Length Required</h1>

After trying several things (trimming, "cfcontent reset" etc) I really couldn't figure out what was going on, and Mr Google didn't help out that much either. Eventually, after more playing, I found a solution - now this may not be the best solution but it works:

When making a AJAX 'POST' to the server (I think) the response header needs to be a certain content type. Simply changing the POST to a GET resolved my issue. Like i said it might not be the best solution but it worked.

Does anyone know why this would be happening and would you mind commenting on a better solution?

My code is:

<script language="javascript" src="/javascript/jquery.js"></script>

   <script type="text/javascript">
      function updateClickCount(feedId) {
      $.ajax({
       type: "GET",
       dataType: "html",
       success: function(response){},
       url: "myURL/feedService.cfc?method=updatedClickCount&feeditemId="+feedId
         });   
      };
   </script>


 
Comments
David Boyer's Gravatar I think I remember running into a similar problem once (although it is Monday morning so take this with a pinch of salf).
Sure it went away after I added some data to the POST request (like a timestamp).
# Posted By David Boyer | 26/11/07 08:03 | Report abusive comment
Rey Bango's Gravatar Post up your code and I'll check it out to see if I can help
# Posted By Rey Bango | 26/11/07 12:13 | Report abusive comment
Nick Tong's Gravatar Hi Ray, thanks - i'd added the AJAX code above
# Posted By Nick Tong | 26/11/07 13:56 | Report abusive comment
Kevin's Gravatar You have to send proper headers etc. See here:

http://www.openjs.com/articles/ajax_xmlhttp_using_...
# Posted By Kevin | 05/12/07 11:05 | Report abusive comment
prashanth's Gravatar LENGHT REQURIED PROBLEM SOLEVED.I am trying to find solution for this problem from last 2 months.u need to use xmlhttp.send(url) insted of xmlhttp.send(null).This will
solve the problem in mozilla.
# Posted By prashanth | 17/01/08 05:58 | Report abusive comment
prashanth's Gravatar xmlhttp.onreadystatechange = functionToCall;
xmlhttp.open("POST",window.location+"?name=test",true);
xmlhttp.send(window.location+"?name=test");
This will solve the problem of "length requried" in mozilla
# Posted By prashanth | 17/01/08 06:02 | Report abusive comment
Dinesh Waitage's Gravatar I think I remember running into a similar problem of 'Length Required',Place 'GET' instead of 'POST'
it working on mozilla but it not best solution,
# Posted By Dinesh Waitage | 02/04/08 06:45 | Report abusive comment
BlogCFC was created by Raymond Camden. This blog is running version 5.5.1.