Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6040325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:29:52+00:00 2026-05-23T06:29:52+00:00

This code worked fine in mvc2, but moving back to traditional ASPX (because of

  • 0

This code worked fine in mvc2, but moving back to traditional ASPX (because of Sharepoint 2010). I am encountering errors. Can anyone tell me what I am doing wrong for this framework?

This ajax call is in the $.ready

$.ajax({
        type: "POST",
        dataType: "json",
        data: 'siteName=a&siteUrl=b',
        url: 'Wizard.aspx/DoesNameUrlExist',
        beforeSend: function () { alert("before send"); },
        complete: function () { alert("complete"); },
        success: function (data) { alert("success"); },
        error: function (data) {
            if ($("meta[name=debug]").attr("content") == "true") {
                //Full Error when debugging
                var errDoc = window.open();
                errDoc.document.write(data.responseText);
                errDoc.document.close();
            }
            else {
                // generic error message for production use
                alert("An unexpected error occurred.");
            } return false;
        }
    });

code behind

[WebMethod]
public static string DoesNameUrlExist(string siteName, string siteUrl)
{
    //do something
    return someString;
}

I get an error everytime.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:29:53+00:00Added an answer on May 23, 2026 at 6:29 am

    You need to send JSON to the service and indicate that you’re doing so via the contentType header:

    $.ajax({
        type: "POST",
        contentType: 'application/json',
        data: '{"siteName":"a","siteUrl":"b"}',
        url: 'Wizard.aspx/DoesNameUrlExist',
        beforeSend: function () { alert("before send"); },
        complete: function () { alert("complete"); },
        success: function (data) { alert("success"); },
        error: function (data) {
            if ($("meta[name=debug]").attr("content") == "true") {
                //Full Error when debugging
                var errDoc = window.open();
                errDoc.document.write(data.responseText);
                errDoc.document.close();
            }
            else {
                // generic error message for production use
                alert("An unexpected error occurred.");
            } return false;
        }
    });
    

    More info here: http://encosia.com/using-jquery-to-directly-call-aspnet-ajax-page-methods/

    Also, if you’re using jQuery 1.4, you can drop the dataType. jQuery will infer JSON automatically based on the response’s Content-Type header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is code that worked fine on Windows XP for years. User is not
I ran this persons code. It worked as a main but when i put
This code worked fine when I used model first aproach. And stoped saving a
My gesture recognition code worked fine in iOS 4.2 but in iOS 4.3 it
I've been scratching my head for quite some time now, this code worked fine
Okay, so I have some code that worked fine in PHP4 but since upgrading
My below code worked fine while running in .NET 4.0 but when I run
This code produces a FileNotFoundException, but ultimately runs without issue: void ReadXml() { XmlSerializer
I was using Ajax.Pager in MVC 2 which worked fine.Here is the code in
I copy and pasted some code that increments an enum: myenum++; This code worked

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.