dongzh1988 2016-05-24 10:03
浏览 11

jquery提交后的数据错过了“with&”

I have a little bug and i don't understand why

I have a form, people submit and i send data with Jquery.

But in input, when people send a link with params &id=data ... i receive in Mysql partial url

My Jquery code : 

$(document).on('click', '.bouton', function(e) {
e.preventDefault(); 
var $this = $(this);
var categorie = $('#categorie').val(); 
var lien = $('#lien').val(); 
var titre = $('#titre').val();      
var dataString5 = 'categorie='+ categorie + '&lien=' + lien + '&titre=' + titre;
$.ajax({
type: "POST",
url: "sendlien.php",
data: dataString5,
cache: false,
success: function(html){

Exemple in Input when people send :

I have in Mysql :

&id=5951454215454 is missed

Many thanks

  • 写回答

1条回答 默认 最新

  • drxd54816 2016-05-24 10:12
    关注

    It's (most likely) an encoding problem. You'd need to encode e.g. spaces (and all other "special" characters) properly ....or.... pass the parameters as an object/hashmap to jquery. It will handle the encoding automagically by default.

    http://api.jquery.com/jquery.ajax/ says:

    processData (default: true)
    Type: Boolean
    By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false.
    $.ajax({
        type: "POST",
        url: "sendlien.php",
        data: {
            "categorie": categorie,
            "lien": lien,
            "titre": titre
        },
        cache: false,
    
    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数