0

我似乎在发送 URL 字符串时遇到问题。URL 如下所示:

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

它在 JS 中发送所有这些信息,但它只有在到达 php 页面后才看起来像这样:

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

我的 Ajax 设置如下:

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

我正在从 PHP 页面收集数据,如下所示:

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

我该如何纠正?

4

3 回答 3

4

您可以使用正确的方式发送帖子参数

jQuery.ajax({
   ...
   data: {param1 : value1, param2: value2}
于 2013-03-21T14:02:01.000 回答
1

尝试encodeURIComponent。这将转义 URL 中的某些字符以符合 UTF-8 标准。

var encodedURL = encodeURIComponent(str);
于 2013-03-21T14:05:07.780 回答
0

将您的数据更改为:

data: {type: "add", 1A: "pubName"....//and so on},

您必须在值周围加上引号。

于 2013-03-21T14:05:29.833 回答