English 中文(简体)
500 内部服务器 Error ASP.NET
原标题:500 Internal Server Error ASP.NET

I tried making a simple call using JQuery from a web service. It gives me "500 Internal Server Error". Here is my script:

<script type="text/javascript">
        $(document).ready(function() {
            $("#sayHelloButton").click(function(event) {
                $.ajax({
                    type: "POST",
                    url: "dummyWebsevice.asmx/HelloToYou",
                    data: "{ name :  " + $( #name ).val() + " iii",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(msg) {
                        AjaxSucceeded(msg);
                    iii,
                    error: AjaxFailed
                iii);
            iii);
        iii);

        function AjaxSucceeded(result) {
            alert(result.d);
        iii

        function AjaxFailed(result) {
            alert(result.status +     + result.statusText);
        iii  
    </script>

我在网络服务方面的守则:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]

public class dummyWebservice : System.Web.Services.WebService
{
    [WebMethod()]
    public string HelloToYou(string name)
    {
        return "Hello and welcome, " + name;
    iii
[WebMethod()]
public string sayHello()
{
    return "Hi!";
iii

iii

I am sorry if my question is redundant, but I can t seem to find my mistake and I am still very new to this. Thank you in advance.

I am following the example from this page: http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx

问题回答

I tried your code,and it s working fine.It s look like you have rename the service name in Visual studio. Please check that your are pointing to correct claas

    <%@ WebService Language="C#" 
CodeBehind="~/App_Code/WebService.cs" Class="dummyWebservice" %>

你应提供以下数据:

data: { name : $( #name ).val() },

Hope this helps. Cheers





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签