duanjiaren8188 2012-04-24 12:43
浏览 58

使用base64编码的字符串将XML从Javascript发送到PHP

I have to send an XML via Javascript to PHP and am doing this via jQuery like this:

$.ajax({
           url             :   'http://myurl',
           type            :   'POST',
           data            :   { documentXML : escape(xml) },
           dataType        :   'text',
           success         :   function( data ) {
              // Do something
           },
           error           :   function() {
              alert('Failed to send ajax request!');
           }
        })

I'm decoding the xml in PHP like this:

if(isset($_REQUEST['documentXML'])) {
    $receivedXML = urldecode($_REQUEST['documentXML']);
} else {
   die('<?xml version="1.0"?><error>No documentXML given.</error>');
}

However, inside the XML there are other XMLs embedded; this is done by base64 encoding the embedded XMLs. The base64 turns invalid during this process.

Given that changing the XML structure or the encoding is not an option:

  • what can I do?
  • is the way I'm doing this the right approach?

Thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突
    • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
    • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序