Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Error 414. The request URL is too long

I am using ckeditor to format some data inside my textarea

<textarea id="editorAbout" rows="70" cols="80" name="editorAbout"></textarea>

Now when i try to post this data using jQuery.ajax like this,

var about=escape( $("#editorAbout").text());
            $.ajax({
             type: "POST",
             url: "../Allcammand.aspx?cmd=EditAboutCompany&about="+about,
             type:"post",
                async: false ,
                   success: function(response){                                       

                    },
                    error:function(xhr, ajaxOptions, thrownError){alert(xhr.responseText); }
            });

I get the error

HTTP Error 414. The request URL is too long.

I am getting the error here: http://iranfairco.com/example/errorLongUrl.aspx
Try clicking on the Edit Text button at the bottom left of that page.

Why is this happening? How can I solve it?

like image 988
ashkufaraz Avatar asked Aug 05 '11 11:08

ashkufaraz


3 Answers

According to this question the maximum practical length of a URL is 2000 characters. This isn't going to be able to hold a massive Wikipedia article like you're trying to send.

Instead of putting the data on the URL you should be putting it in the body of a POST request. You need to add a data value to the object you're passing to the ajax function call. Like this:

function editAbout(){

    var about=escape( $("#editorAbout").text());
    $.ajax({
        url: "Allcammand.aspx?cmd=EditAboutCompany&idCompany="+getParam("idCompany"),
        type:"post",
        async: false,
        data: {
            about: about
        },
        success: function(response){                                       
        },
        error:function(xhr, ajaxOptions, thrownError){alert(xhr.responseText); ShowMessage("??? ?? ?????? ??????? ????","fail");}
    });
}
like image 74
alnorth29 Avatar answered Oct 11 '22 07:10

alnorth29


For me, changing type:"get" to type:"post" worked, as get reveals all queries and hence make it bigger url.
Just change type from get to post.
This should help. :)

like image 2
Yash Avatar answered Oct 11 '22 06:10

Yash


In my case, there was a run-time error just before the post call. Fixing it resolved the problem.

The run-time error was trying to read $('#example').val() where $('#example') element does not exist (i.e. undefined).

I'm sure this will, certainly, help someone.

like image 1
Shadi Namrouti Avatar answered Oct 11 '22 07:10

Shadi Namrouti