2011-08-05 189 views
7

我使用CKEditor的一些數據格式在我的textareaHTTP 414錯誤的請求URL太長

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

現在,當我嘗試後使用jQuery.ajax這樣這個數據,

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

我得到錯誤

HTTP錯誤414.請求URL太長。

我正在這裏的錯誤:在底部的編輯文本按鈕http://iranfairco.com/example/errorLongUrl.aspx
嘗試點擊左邊那一頁。

這是怎麼發生的?我該如何解決它?

+0

那麼,你會在網址中添加**噸**的文字。 URL不是爲了處理這個問題。您應該發送POST正文中的文本,而不是嘗試將其放入URL中。 –

+0

愛你發佈,但它確實是一個GET。 :) – epascarello

回答

17

根據this question一個URL的最大實際長度是2000個字符。這不可能像你想要發送的那樣保存大量的維基百科文章。

而不是把數據放在URL上,你應該把它放在POST請求的主體中。您需要爲要傳遞給ajax函數調用的對象添加一個data值。像這樣:

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

如何可以在'allCommand.aspx'接收數據(約) – ashkufaraz

+0

我可以通過請求得到這個[「about」] – ashkufaraz

+0

當所有的命令重擊超過20000字符,然後... $ .ajax({url:「Allcammand .aspx?cmd = getAbout&idCompany =「+ getParam(」idCompany「), async:false, success:function(response){alert(response); } }); – ashkufaraz

0

在我的情況下,即使我使用'POST'並且對服務器的調用成功,也會引發錯誤。它變成,我錯過了dataType屬性...奇怪,但現在它的工作

  return $.ajax({ 
      url: url, 
      type: 'POST', 
      dataType: 'json', 
      data: JSON.stringify(data) 
     }) 
1

在我的情況,有一個運行時錯誤就在後調用。修復它解決了問題。

的運行時錯誤試圖讀$('#example').val()其中$('#example')元素不存在(即undefined)。

我相信這肯定會幫助別人。

相關問題