0

First time I've ever encountered this strange situation. I've already worked with Ajax and parameters of different types. I tried it to solve with contentType, but it didn't seem to work.

I tried to play with formats like UTF-8 of the document, and contentType as mentioned above.

$.ajax({
    url: "/Test",
    type: "POST",
    data: 
    {
        'ID':$(this).attr("ID"),
        'Date':$(this).attr("Date")
    },
    dataType: "json",
    cache: false
})

ID=12345&Date=01.01.2018+00%3A00%3A00 // Is

ID=12345&Date=01.01.2018 00:00:00 // Should be

Because of this I cannot convert it to a double type in Delphi (Rad Studio):

Variant of Type (UnicodeString) could not be converted into Double

erikrunia
  • 2,371
  • 1
  • 15
  • 22
René
  • 1
  • 4
  • 1
    I don't see the connection with Delphi. Please elaborate, how is this related to Delphi? – Jerry Dodge Jul 17 '18 at 14:37
  • The Problem itself is not related to Delphi, i just thought it may help unterstanding the Situation better. Also maybe someone had the same Problem in the same Situation and can recognize it easier. I can remove it, if it should not be mentioned. – René Jul 17 '18 at 14:47
  • Your data has been html encoded. You can html decode it if need be. – erikrunia Jul 17 '18 at 14:51
  • Missinterpreted the failure, it comes from my delphi application, but still thanks for all comments it may be helpful in the future. – René Jul 18 '18 at 08:42

1 Answers1

0

Your string has been html encoded. Html Decode it on your server side before converting it to a Date (or double in your case?).

Most ajax libraries will do this automatically. That is probably what yours is doing, hence the html encoding in your date strings. It is strange you've never noticed it before, as it's rather normal behavior on a post.

To fix in Delphi, look at the HTTPApp unit. HTTPDecode and HTMLDecode (as well as the Encode functions). You should find this in your Source/Win32/Internet folder.

See this SO question as the above paragraph answer came from there.

erikrunia
  • 2,371
  • 1
  • 15
  • 22