Well this is wrong
data: { UserName:username, Password:password },
Should be something like this
var jData = "{" +
"\"m_firstName\" : \"" + txt_FirstName_enc + "\", " +
"\"m_lastName\" : \"" + txt_LastName_enc + "\", " +
"}";
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "connect.asmx/send_Connection",
data: jData,
dataType: "json",
error: function (xhr, status, error) {
exitCode = 2;
alert(xhr.responseText);
},
success: function (responseText) {
try {
eval('(' + responseText.d + ')');
}
catch (err) {
}
var obj = jQuery.parseJSON(responseText.d);
var exitCode = obj.exitCode;
And then your web service
With json_response
.Append("{")
.Append(" ""exitCode"" : " & exitCode.ToString)
.Append("}")
End With
Dim js As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer
js.Serialize(json_response.ToString)
Return json_response.ToString
Well, since you gave us pieces of code, you get pieces back. Run the json data string through a validator before sending it, and run the web service json response string through a validator to make sure it's good.
Google json validator