PDA

View Full Version : JQuery $.post ERROR with long string



JasonDFR
07-22-2009, 07:07 PM
If I attempt to post a string longer than 192 characters (including spaces) with the code below, an error occurs and nothing is submitted. 192 characters plus any amount of whitespace is ok. If the 193rd character is any letter for example, it won't work.

Error: uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://family.localhost/js/jquery-min.js :: anonymous :: line 12" data: no]

1) Is there a limit on string length in a key/value pair?
2) If not, what could cause my error?
3) Any problems with the code below? Suggestions for improvement?


$(function()
{
$("form#new_message").submit(function()
{
var message = $("#message").get(0);

var errorMsg = 'You must type a message before clicking submit';

if ( message.value == '' || message.value == errorMsg )
{
message.value = 'You must type a message before clicking submit';
return false;
}

$.post("/messageboard/postnew" , { message: $("#message").get(0).value } ,
function(response)
{
var ajaxResponse = $(response);

$("#messages").replaceWith(ajaxResponse.hide().fadeIn(450));

message.value = '';

});
return false;
});

});

Thanks a lot.

JasonDFR
07-22-2009, 07:32 PM
Nevermind. The validator in my php script is throwing an error and the call back function in the javascript I posted does not know how to handle it.

Might have another question later.

Thanks.