I've got a web form where I'm creating a couple of textboxes dynamically using jquery. I also need to build a dropdown list from a database call using jquery.
I created a test project and got the code working but when I moved over it into the development project, I'm having issues with the ajax section of the code. It fails and I get the error alert.
Here's the jquery/ajax:
<script type="text/javascript">$(document).ready(function () {$("#btnAdd").click(function () {
var newRow2 = "<br /><label>Additional Issue: </label><br /><input type='text' size='50' name='addIssue' id='field' value='' /><br /><br /><label>Description:</label><br /><textarea rows='8' cols='80' name='addProblem' id='field' ></textarea><br /><br />"$('#controls').append(newRow2);$.ajax({
url: "GetCategory.asmx/HelloWorld",
dataType: "json",
type: "POST",
data: "{}",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.d)$('#controls').append("Category:" + data.d + "<br /><br />");
},
error: function () {
alert("Ajax Error");
}
});
});
});</script>And here is the code in the asmx file:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _<ToolboxItem(False)> _
Public Class GetCategory
Inherits System.Web.Services.WebService<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End ClassWhen I run this, the ajax call comes back with an error. (Yeah, I scaled down the code to see if I could retrieve anything)
I've tried using the ajax call with the asmx file as well as the .vb file of the webform. I've tried using
<%=ResolveUrl("~/GetCategory.asmx/HelloWorld") %>as the url of the ajax url in addition to what I used above.
I'm stumped. It's as if the service can't be found or the function can't be found. Any thoughts?