Reputation: 3509
I want to send data to a camera, and it only accepts the data when it has no encoding to it.
The data should look like
<?xml version="1.0" encoding="UTF-8"?>
<EventTriggerList version="2.0">
...
</EventTriggerList>
I have a function that creates that string just fine, and when I use it via an application to send to the camera, it works. But when I use Ajax:
$.ajax({
url: target,
type: 'PUT', //type is any HTTP method
contentType: "application/xml",
data: {
data: dataString
},
success: function () {
}
})
;
it sends the above as
<?xml+version="1.0"+encoding="UTF-8"?>
<EventTriggerList+version="2.0">
...
</EventTriggerList>
and the camera won't accept it. I tried setting processData to false, but then my payload is only 15 bytes, instead of the expected 300 bytes of string.
How do I get the payload to be precisely as the string I generated?
Upvotes: 1
Views: 37
Reputation: 97672
Since your content type is xml and dataString is also xml, just pass it as is
$.ajax({
url: target,
type: 'PUT', //type is any HTTP method
contentType: "application/xml",
data: dataString,
success: function () {
}
})
Upvotes: 1