10

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?

naveen
  • 53,448
  • 46
  • 161
  • 251
ashkufaraz
  • 5,179
  • 6
  • 51
  • 82

5 Answers5

25

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");}
    });
}
Community
  • 1
  • 1
alnorth29
  • 3,525
  • 2
  • 34
  • 50
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. :)

Yash
  • 369
  • 5
  • 18
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.

Shadi Alnamrouti
  • 11,796
  • 4
  • 56
  • 54
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)
        })
usefulBee
  • 9,250
  • 10
  • 51
  • 89
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.

Yeronimo
  • 1,731
  • 15
  • 28