douliu7929 2013-03-21 13:59
浏览 54
已采纳

JQuery Ajax通过URL字符串发送

I seem to be having problems with sending over a string of a URL. The URL looks like this:

http://www.thewebsitehere.com/mf2/stuff/dirhere.asp?sid=&nm=&type=Publishing&mod=Publions::Article&mid=8F3A7027421F87F791&SiteID=B824D34CAB8727A06DEA3467&tier=4&id=8964A4D50BB59A0AD48594A

Its sending all that information inside the JS but it only looks like this once it gets to the php page:

http://www.thewebsitehere.com/mf2/stuff/dirhere.asp?sid=

My Ajax is set up like so:

jQuery.ajax({
    type: "POST",
    dataType: "html",
    data: "type=add" + "&1A=" + pubName + "&1B=" + postID + "&1C=" + PostTitle + "&1D=" + timeStamp + "&1E=" + pdfLink + "&1F=" + imgLink + "&1G=" + fullArticleLink,
    url: "../wp-content/plugins/visual-editor-custom-buttons/js/wpDataSend.php",
    success: function(results) {
        if (results.indexOf("done") >= 0) {
            showNotifier(8000,'#43d32b','Title, Pub Name, Image, Date, PDF & Article link have been saved!');
        } else {
             showNotifier(8000,'#d32b2b','Could not save... Please try again!');
        }
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
        console.log("Status: " + textStatus);
        console.log("Error: " + errorThrown);
        showNotifier(8000,'#d32b2b','Error: ' + textStatus + ' | ' + errorThrown);
    }
});

And I am gathering up the data from the PHP page like so:

$newtype     = $_POST['type'];
$pubName     = $_POST['1A'];
$postID     = $_POST['1B'];
$PostTitle     = $_POST['1C'];
$timeStamp     = $_POST['1D'];
$pdfLink     = $_POST['1E'];
$imgLink     = $_POST['1F'];
$Fullarticle   = $_POST['1G'];

How can I correct this?

  • 写回答

3条回答 默认 最新

  • dpymrcl269187540 2013-03-21 14:05
    关注

    Try encodeURIComponent. This will escape certain characters in the URL to conform with UTF-8 standards.

    var encodedURL = encodeURIComponent(str);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么