Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    POST character limit? using .open and .send

    hi all,

    first a bit of background i have been working on an autosave script which will save text input into a text area every 30 seconds, i appear to be getting an Invalid URL error when the character limit reaches around 2,700(firefox) and 1600(IE) characters.

    here is the bit of code which sends the request:

    Code:
    	function sndReq(area, msg) 
    	{
    		currentarea = area;
    		currentmsg = msg;
    		if(currentarea != "" && currentmsg != "")
    		{
    			timer = setTimeout("sndReq(currentarea, currentmsg)",30000);
    		}
    		
    		text = document.getElementById(area).value;
    		text = escape(text);
    		
    		data = '&msg='+msg+'&text='+text+'&area='+area;
    
    		var url = "autosave.php";
    		http.open('POST', url, true);
    		http.send(data);
    		
    		//Send the proper header information along with the request
    		http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    		http.setRequestHeader("Content-length", data.length);
    		http.setRequestHeader("Connection", "close");
    		http.onreadystatechange = handleResponse;
    	}
    and the text area code:

    Code:
    <textarea name="if_Comment.0001" id="if_Comment.0001" cols="85" rows="5" 
    				 onFocus="sndReq(this.id, 'comment');" onBlur="stopCount(this.id, 'comment');"></textarea>
    <div id="comment"></div>
    I havnt posted the bit of code that handles the response, as that appears to be fine, when the save is completed by autosave.php the div with the id comment is updated to represent that the save has been completed sucessfully/unsucessfully.

    I would appreciate any help anyone can give on this matter.
    Last edited by dodge245; 01-24-2011 at 03:36 PM.

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Don't know if this pertains to your problem, but the order in which you're doing things is off:

    The headers and the readystatechange callback are supposed to be set after open, but before send.

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Quote Originally Posted by shellyk View Post
    I do not have an idea about the topic you are talking about, but I will surely love to help yopu in future if it is possible for me.
    ========
    That's pathetic. My mum could write a better spam bot than you.

    Now go away, you irritating little drone.

  • #4
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thankyou for the response, unfortunately moving the code didnt appear to affect anything.

    my worry is that the code could still be using the GET protocol instead of the POST Protocol. Here is a Screenshot of the error:



    As mentioned this error only happens when the textarea reaches a certain character limit.

    I am curious if this could be the problem: http://support.microsoft.com/kb/208427

    Microsoft Internet Explorer has a maximum uniform resource locator (URL) length of 2,083 characters. Internet Explorer also has a maximum path length of 2,048 characters. This limit applies to both POST request and GET request URLs.
    Last edited by dodge245; 01-25-2011 at 10:31 AM.

  • #5
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    I don't really get why you're having those problems. I just tried your code (modified, so it's in the right order), and it works like a charm.

    The URL limit you mentioned does not pertain to the actual POST data, so that's not it.

    Please provide a link to an example site, so I can see your code in action.

  • Users who have thanked venegal for this post:

    dodge245 (01-25-2011)

  • #6
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by venegal View Post
    I don't really get why you're having those problems. I just tried your code (modified, so it's in the right order), and it works like a charm.

    The URL limit you mentioned does not pertain to the actual POST data, so that's not it.

    Please provide a link to an example site, so I can see your code in action.
    well thats infuriating lol, i cant give you access to the actual site so i started to move the offending code to a test location(same server just different directory) so i could give you access, after moving the code accross and testing, i found that the error has gone.... none of the code has changed

    P.S

    the site is used in a school, and this code is to be used to autosave there personal statements, and other information, and it will also be used on our online reporting platform (imagine a cut down facebook) hence why i cant give you access to the exact area of the site causing issue.

  • #7
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    So, is it only working in the new test location now or has it also started to work in its original location? It could be a cache issue ó maybe the changes in the original location are not yet reflected in your browser?

  • #8
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts
    The code works in the test area but not the original location. I have cleared the Cache of both browsers(IE and Firefox) and there appears to be no change, im at a loss over why the code does not work in the original area.

    I may go back to basics on this and move the site out of the directory and do some more testing, there may be a php.ini file attributed to just that directory causing issues. if i find the solution i will post it here, Thankyou for all your help


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •