Not sure why I am getting this but I get this error:
Invalid web service call, missing value for parameter: \u0027sentQuery\u0027
When trying to execute jQuery AJAX to my ASPX web service.
My AJAX is this:
$.ajax({
type: 'GET',
contentType: "application/json; charset=utf-8",
dataType: 'json',
url: "http://localhost:7665/Service1.asmx/theQ",
data: "{\"sentQuery\":" + "\"SELECT OPRID FROM vwPS_BC_JOB_PERS_DAT\"" + "}",
success: function (data) {
console.log(data);
},
error: function (a) {
alert('ERROR: ' + a.responseText);
}
});
And my VB web service code:
<WebMethod(CacheDuration:=60)> _
<ScriptMethod(UseHttpGet:=True, ResponseFormat:=ResponseFormat.Json, XmlSerializeString:=False)> _
Public Sub theQ(ByVal sentQuery As String)
Dim results As Object = fetchSQLQ("query", sentQuery)
Try
Dim ser As New System.Web.Script.Serialization.JavaScriptSerializer()
Dim strResponse As String = ser.Serialize(results)
Context.Response.Clear()
Context.Response.ContentType = "application/json"
Context.Response.AddHeader("content-length", strResponse.Length.ToString())
Context.Response.Write(strResponse)
HttpContext.Current.ApplicationInstance.CompleteRequest()
Catch ex As Exception
Context.Response.Clear()
Context.Response.ContentType = "application/json"
Context.Response.AddHeader("content-length", ex.Message.Length.ToString())
Context.Response.Write(String.Format("[ERROR: {0}]", ex.Message))
HttpContext.Current.ApplicationInstance.CompleteRequest()
End Try
End Sub
UPDATE
I am guessing that the following is correct:
data: { sentQuery: "SELECT OPRID FROM vwPS_BC_JOB_PERS_DAT" },
However, it does produce another error:
Invalid JSON primitive: SELECT.
Huh????