I have an HTML And JS that sends a SOAP request (using options selected via the pages dropdown options) and deals with the reply.
The reply is displayed in Console.log and saved as a txt.
The initial iteration thought the page sends the correct data from the page and displays the "datapacket" in console, and in the txt files.
Subsequent iterations sends the correct data ( confirmed by using the consoles Network option, locating the POST and looking at the request body), but the Console log (and txt file) ae the previous iterations data.
Initial Code
$('.updatePrices').click(function () {
var Rate = document.getElementById("ID").value;
var Type = document.getElementById("type").value;
var beginDate = $('#start').val();
var endDate = $('#end').val();
var feature = document.getElementById("feature").value;
var price = $('#price').val();
var Plan = $('#plan').val();
var RoomData = '<impl:update> <impl:Rate>' + Rate + '</impl:Rate> <impl:beginDate>' + beginDate + '</impl:beginDate> <impl:endDate>' + endDate + '</impl:endDate> <impl:Type>' + Type + '</impl:Type> <impl:Feature>' + feature + '</impl:Feature> <impl:Code>' + Plan + '</impl:Code> <impl:price>' + price + '</impl:price> </impl:update> ';
dataPacket = dataPacketOpen + updatedataPacket + RoomData;
dataPacket = dataPacket + updatedataEnd + dataPacketClose;
console.log(dataPacket);
$.ajax({
url: wbURL,
dataType: "xml",
contentType: "text/xml; charset=\"utf-8\"",
type: "POST",
headers: 'OMMITED',
data: dataPacket,
success: dealWithResponse,
error: UpdatePricexmlError
});
});
Response Function (which is where I think the issue is, but I cannot see it )
The dataPacket doesn't get replaced with the newer version, but I cannot see why not
I have tried adding a datapacket=""; line to the beginning, but although the data gets sent out ok (again, checked using the network tab in the console) the txt and console display are blank.
Subsequent iterations sends the correct data ( confirmed by using the consoles Network option, locating the POST and looking at the request body), but the Console log (and txt file) ae the previous iterations data.
We can see no iterations in your code used to change the value of datapacket. I mean it just should be displaying the previous data since it's not changed anywhere in your code.
The whole process shoul be: click the updatePrices to fire the function -> set value for your dataPacket -> console.log(dataPacket) -> use Ajax and put the dataPacket as the data -> if the behind event completed successfully, fire the success event of your
Ajax which is dealWithResponse -> create a txt file.
The console.log(dataPacket) was fired once and never again in your code, are you talking about that you clicked the updatePrices again? If so, the value of dataPacket is totally based on those several controls' value.
Not really understand the problem, maybe you could decribe more detailly with more information?
Member
5 Points
50 Posts
SOAP post: correct data being sent, wrong data being display
Dec 06, 2019 02:44 PM|G-Oker|LINK
HI,
I have an HTML And JS that sends a SOAP request (using options selected via the pages dropdown options) and deals with the reply.
The reply is displayed in Console.log and saved as a txt.
The initial iteration thought the page sends the correct data from the page and displays the "datapacket" in console, and in the txt files.
Subsequent iterations sends the correct data ( confirmed by using the consoles Network option, locating the POST and looking at the request body), but the Console log (and txt file) ae the previous iterations data.
Initial Code
Response Function (which is where I think the issue is, but I cannot see it )
The dataPacket doesn't get replaced with the newer version, but I cannot see why not
I have tried adding a datapacket=""; line to the beginning, but although the data gets sent out ok (again, checked using the network tab in the console) the txt and console display are blank.
Why is it displaying the previous data?
what can I do to resolve it ?
Thanks in advance
Contributor
3140 Points
983 Posts
Re: SOAP post: correct data being sent, wrong data being display
Dec 09, 2019 07:18 AM|Yang Shen|LINK
Hi G-Oker,
We can see no iterations in your code used to change the value of datapacket. I mean it just should be displaying the previous data since it's not changed anywhere in your code.
The whole process shoul be: click the updatePrices to fire the function -> set value for your dataPacket -> console.log(dataPacket) -> use Ajax and put the dataPacket as the data -> if the behind event completed successfully, fire the success event of your Ajax which is dealWithResponse -> create a txt file.
The console.log(dataPacket) was fired once and never again in your code, are you talking about that you clicked the updatePrices again? If so, the value of dataPacket is totally based on those several controls' value.
Not really understand the problem, maybe you could decribe more detailly with more information?
Best Regard,
Yang Shen
Member
5 Points
50 Posts
Re: SOAP post: correct data being sent, wrong data being display
Dec 10, 2019 06:17 PM|G-Oker|LINK
You are quite correct. I had not put any iterations/ variable declarations in the deal wit response function.
thank you