简体   繁体   中英

Encode URL for AJAX POST data

I was using encodeURIComponent to encode an URL but I'm getting 500 SERVER ERROR on some urls, I'm sure the problem is in the encoding since removing the data solves the error completely.

How do I encode the URL so that I can retrieve it in the other end and not have problems in the call?

    $.ajax({type:'POST',url: "/insert-url.php", data: 'url='+encodeURIComponent(link)',
        success:function(data_response){
            }
        });
$.ajax({type:'POST',url: "/insert-url.php", 
        data: 'url='+encodeURIComponent(link)**-->'<---**,
        success:function(data_response){
        }
});

a ' too much

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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