HTTP Error 414. The request URL is too long
Asked Answered
F

6

11

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?

Fairish answered 5/8, 2011 at 11:8 Comment(2)
Well, you append tons of text to the URL. URL are not designed to handle that. You should send the text in the body of the POST instead of trying to put it in the URL.Blest
Love that you are posting, but it really is a GET. :)Fadein
S
26

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");}
    });
}
Suborbital answered 5/8, 2011 at 11:22 Comment(4)
i can get this by request["about"]Fairish
when allcommand retrun more than 20000 character then... $.ajax({ url: "Allcammand.aspx?cmd=getAbout&idCompany="+getParam("idCompany"), async: false, success: function(response){alert(response); } });Fairish
The call in your comment does not pass the data.Suborbital
@GodIsLive - was your comment about having a further problem or does this answer solve your problem?Suborbital
G
2

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

Gravettian answered 13/7, 2020 at 18:53 Comment(0)
O
1

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.

Outpatient answered 14/8, 2017 at 13:27 Comment(0)
S
0

In my case, the error was raised even though I was using 'POST' and the call to the server was successful. It turned to be that I was missing the dataType attribute...strange but now it works

            return $.ajax({
            url: url,
            type: 'POST',
            dataType: 'json',
            data: JSON.stringify(data)
        })
Senskell answered 23/7, 2015 at 15:22 Comment(0)
P
0

A bit late to the party, but I got this 414, while using POST. It turned out is was a max path length in windows causing this error. I was uploading a file, and the actual request length was just fine (using post). But when trying to save the file, it exceeded the default 260 char limit in windows. This then resulted in the 414, which seems odd. I would just expect a 501. I would think 414 is about the request, and not the server handling.

Prosser answered 11/2, 2021 at 16:23 Comment(0)
B
0

I had the same error, but since I had to use GET method to allow users to later click the browser's Back button without the need to re-submit the form again.

I went back to check the code and found that I had included the textarea into the action form scope, while in fact I didn't need to include it in that same form.

I placed the textarea into a new form outside of the form that requires the submit action button and everything went well.

Boomerang answered 8/5 at 8:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.