I am currently working on a simple asp.net web application that utilizes YUI for Ajax requests. The application reads text from a text box and sends an AJAX request to the server. Below is the code snippet:
<body>
<form id="form1" runat="server">
<div>
<input id="txt" name="txt" type="text" value="[Enter some value]" />
<input id="btn" type="button" value="button" />
</div>
<div id="out"></div>
</form>
</body>
Additionally, here is the client script responsible for initializing the Ajax request:
YAHOO.util.Event.onDOMReady(function() {
YAHOO.util.Event.addListener("btn", "click", function(evt) {
var url = "Server.aspx?type=test&txt=" + document.getElementById("txt").value;
var btn = document.getElementById("out");
var cObj = YAHOO.util.Connect.asyncRequest('GET', url, {
success: function(o) {
btn.innerHTML += "<div>" + o.responseText + " = " + o.responseText.charCodeAt(0) + "</div>";
},
failure: function(o) {
confirm("Its failure");
},
cache: false
});
});
});
The problem I am encountering in the application relates to character encoding. When the special character "Registered" ® (0174) is entered in the text box and sent to the server, it is being displayed as #65533 in the response instead of retaining its original form. This behavior is unexpected since the ® symbol is not a Unicode character. I need assistance in resolving this issue.