我通过ajax将xml发布到我的php页面以下是客户端cod这里我正在创建我的xml并发布到php页面,我已经尝试在php.ini文件中进行设置但是它不适用于我
var issuedetails = JSON.stringify(issues);
passdata = "<passdata><fdata>" +
"<req_date>" + req_date + "</req_date>" +
"<req_time>" + req_time + "</req_time>" +
"<customer_number>" + customer_number + "</customer_number>" +
"<customer_name>" + customer_name + "</customer_name>" +
"<customer_address>" + customer_address + "</customer_address>" +
"<customer_locality>" + customer_locality + "</customer_locality>" +
"<customer_city>" + customer_city + "</customer_city>" +
"<customer_email>" + customer_email + "</customer_email>" +
"<channel>" + channel + "</channel>" +
"<serviceType>" + serviceType + "</serviceType>" +
"<vehicle_type>" + vehicle_type + "</vehicle_type>" +
"<vehicle_number>" + vehicle_number + "</vehicle_number>" +
"<vehicle_make>" + vehicle_make + "</vehicle_make>" +
"<vehicle_model>" + vehicle_model + "</vehicle_model>" +
"<vehicle_variant>" + vehicle_variant + "</vehicle_variant>" +
"<vehicle_segment>" + vehicle_segment + "</vehicle_segment>" +
"<fuel>" + fuel + "</fuel>" +
"<category>" + category + "</category>" +
"<manf_year>" + manf_year + "</manf_year>" +
"<kmreading>" + kmreading + "</kmreading>" +
"<lastservice>" + lastservice + "</lastservice>" +
"<issues>" + issuedetails + "</issues>" +
"<action>" + "submit_new_customer_booking" + "</action>" +
"</fdata></passdata>";
}
Jprocessingstart();
$.ajax({
type: "POST",
url: "model_booking_table.php",
data: "data=" + encodeURIComponent(passdata),
success: function (data, textStatus, jqXHR)
{
},
error: function (jqXHR, textStatus, errorThrown)
{
// alert("fail");
alert("some error occured->" + jqXHR.responseJSON);
}
}).done(function (msg) {
alert("Booking done successfully!");
Jprocessingend();
location.reload();
// BookingConfirmationCommunication();
});
我发布到php的数据
<passdata><fdata><req_date>2017-09-26</req_date><req_time>10:30</req_time><customer_number>9673******</customer_number><customer_name>rahul</customer_name><customer_address>CST no 235 & 239, Sonai Apt, Office no 3, Upper grnd flr, near lokmanya vachnalay</customer_address><customer_locality>Sadashiv Peth-411030</customer_locality><customer_city>Pune</customer_city><customer_email>******************@gmail.com</customer_email><channel>Direct</channel><serviceType>Dry</serviceType><vehicle_type>TW</vehicle_type><vehicle_number></vehicle_number><vehicle_make>TVS</vehicle_make><vehicle_model>Jupiter</vehicle_model><vehicle_variant>Select</vehicle_variant><vehicle_segment></vehicle_segment><fuel></fuel><category></category><manf_year></manf_year><kmreading></kmreading><lastservice></lastservice><issues>[{"issue":"Meter not working","diagnosis":"Speedo Meter cable broke, Speedo meter gear broke, Speedo meter unit damage","solution":"1) Speedometer Cable: Check / Replace 2) Speedometer Gear: Check / Replace 3) Assembly: Replace","parts":"Speedometer Cable Speedometer Gear Speedometer Assly","comments":"","estimate":""}]</issues><action>submit_new_customer_booking</action></fdata></passdata>
我在php上收到的数据
<passdata><fdata><req_date>2017-09-26</req_date><req_time>10:30</
req_time><customer_number>9673******</customer_number><customer_name>rahul</
customer_name><customer_address>CST no 235 & 239, Sonai Apt, Office no 3, Upper grnd flr, near lokmanya
vachnalay</customer_address><customer_locality>Sadashiv Peth-411030</
customer_locality><customer_city>Pune</customer_city><customer_email>******************@gmail.com</
customer_email><channel>Direct</channel><serviceType>Dry</serviceType><vehicle_type>TW</
vehicle_type><vehicle_number></vehicle_number><vehicle_make>TVS</
vehicle_make><vehicle_model>Jupiter</vehicle_model><vehicle_variant>Select</
vehicle_variant><vehicle_segment></vehicle_segment><fuel></fuel><category></category><manf_year></
manf_year><kmreading></kmreading><lastservice></lastservice><issues>[{"issue":"Meter not
working","diagnosis":"Speedo Meter cable broke, Speedo meter gear broke, Speedo meter unit
damage","solution":"1) Speedometer Cable: Check / Replace 2) Speedometer Gear: Check / Replace 3) Assemb
我收到Assemb后丢失的数据,我使用以下代码
接收帖子数据
$preceivedata = $_POST['data'];
答案 0 :(得分:0)
问题是我的xml中的标记包含&#39;&amp;&#39;字符&#39; CST no 235&amp; 239,Sonai Apt,Office no 3,Upper grnd flr,靠近lokmanya vachnalay&#39; , 这使得它无效的xml,我尝试了一些解决方案,如java脚本的encodeURIComponent(),escape()函数,但它没有用,什么工作是&#39;替换&#39; javascript的功能, 在将值放入标签之前我做了
它解决了我的问题