0

I am submitting data to a classic ASP page via Ajax but the receiving page loses some of the parameter values that I have submitted. I use the url of the ajax call to pass parameters. In the ASP page I am reading the parameters from the URL via the Request method. The issue I'm having is that for one of the parameters when I do Request(), it is stripping away the special characters.

For example, if I have 'C++' or 'C&' or '10 + 10', the pluses and & don't appear in the value I am getting from Request(). I also tried doing Request.QueryString() and changing the Codepage value to 65001 but none of these methods worked.

In the ajax call, I see that the value is going in correctly with the special characters all there.

Here is my simple ajax call:

$.ajax({
    url: "processUpdateComment.asp?timeIn=" + timeIn + "&computerName=" + 
    computerName + "&comments=" + comments,
    type: "POST",
    dataType: "html"
});

The parameters being passed in are just being obtained from html elements via jQuery.

Vanquished Wombat
  • 9,075
  • 5
  • 28
  • 67
  • There is quite a lot that could be going wrong here from the encoding set on your ajax process to the way you are interpreting the data received at the server. Please post a simple, cut down example of your code that exhibits the issue you are seeing. – Vanquished Wombat Nov 30 '17 at 18:33
  • I have added my ajax call that I am making to my original post there. So before I make the ajax call I added some alert statements and I see the parameters are going into the ajax correctly. – A. Kaushal Nov 30 '17 at 18:38
  • 1
    Ok thanks. So your data that you append to the url is assumed by the browser to be URI encoded but it is not. Take a look at this answer https://stackoverflow.com/questions/6544564/url-encode-a-string-in-jquery-for-an-ajax-request – Vanquished Wombat Nov 30 '17 at 19:17
  • 1
    Perfect, that did the trick. Thanks – A. Kaushal Nov 30 '17 at 19:25

0 Answers0