简体   繁体   English

如何通过AJAX jQuery发布长字符串?

[英]How to post long string via AJAX jQuery?

I want to send long string with $form.serialize() data as follows. 我想发送带有$form.serialize()数据的长字符串,如下所示。

var $form = $( this ),
url = $form.attr( "action" );
$.ajax({
    url: APP_URL+'/packs/add',
    type: 'POST',
    data: $form.serialize() + '&url=' + JSON.stringify(downloadURL),
    dataType: 'json'
}).done(function(data){

});

The downloadURL is long string and it post half of them and lost the other part. downloadURL是一个长字符串,它会发布其中一半,而丢失另一部分。 How to post full string? 如何发布完整字符串?

Assuming downloadURL is a string you would have to encode the string with encodeURIComponent 假设downloadURL是一个字符串,则必须使用encodeURIComponent对该字符串进行编码

$.ajax({
    url: APP_URL+'/packs/add',
    type: 'POST',
    data: $form.serialize() + '&url=' + encodeURIComponent(downloadURL),
    dataType: 'json'
}).done(function(data){

});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM