...

View Full Version : POST character limit? using .open and .send



dodge245
01-24-2011, 03:33 PM
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:



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:



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

venegal
01-24-2011, 05:19 PM
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.

Spudhead
01-25-2011, 10:24 AM
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 (http://www.codingforums.com/search.php?searchid=6692010).

Now go away, you irritating little drone.

dodge245
01-25-2011, 10:28 AM
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:

http://farm6.static.flickr.com/5216/5387199412_9637bd683f.jpg

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.

venegal
01-25-2011, 10:52 AM
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.

dodge245
01-25-2011, 11:30 AM
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 :eek::mad:

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.

venegal
01-25-2011, 11:50 AM
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?

dodge245
01-25-2011, 01:06 PM
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 :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum