Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
788 views
in Technique[技术] by (71.8m points)

javascript - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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");}
    });
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...