Tom Knowlton
asked on
getting ajax call to work
Here is my ajax call:
Here is the web service code:
So far it is failing ( I get the alert that says "did not work" )
I could use some help. Thanks!
Tom
$.ajax({
type: "GET",
url: "WebGlobalMethods.asmx/HelloWorld",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: TheTextFound,
error: LoadFailed
});
function TheTextFound()
{
alert("success");
}
function LoadFailed()
{
alert("did not work");
}
Here is the web service code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace Campus_Webstore
{
/// <summary>
/// Summary description for WebGlobalMethods
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebGlobalMethods : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
So far it is failing ( I get the alert that says "did not work" )
I could use some help. Thanks!
Tom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yep, that was it. It needed to be POST.
As leakim971 said, try the attached code.
Thanks,
Richard
Open in new window