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 6902465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:48:05+00:00 2026-05-27T07:48:05+00:00

I have a webmethod hosted on domain A inside a .aspx page. I need

  • 0

I have a webmethod hosted on domain A inside a .aspx page. I need to call this method from domain B. I am using $getJSON() to make this call, but when it comes back data.query.results[0] is always null.

Jquery code in domain B.

// Accepts a url and a callback function to run.
function requestCrossDomain() {
    var site = 'http://domain A/Services/A.aspx/GetString'; 
    var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + site + '"') + '&format=json&callback=?';

    $.getJSON(yql, cbFunc);

    function cbFunc(data) {
        if (data.query.results[0]) {
            var result = JSON.parse(data.results[0]);
            alert(result);
        }
        else 
            throw new Error('Nothing returned from getJSON.');
    }
}

Domain A Webmethod

<WebMethod()> 
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)>
Public Shared Function GetString() As String
    Dim ResultString As String = New JavaScriptSerializer().Serialize("Test Result")
    Return ResultString
End Function

The above method works absolutely fine when I call the method from the same domain. But cross domain call always returns null.

When I checked in Fiddler, there is track that says the server responded and the content length is 616. But the result I get back is null.

Response Headers

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcQ29tbW9uXFBST1xIUk9cU2VydmljZXNcSFJPQ29yZS5hc3B4?=
X-Powered-By: ASP.NET
Date: Mon, 05 Dec 2011 15:07:54 GMT
Content-Length: 616

I am not sure what I am missing. I’ve tried using JSONP and $getJSON. Both doesn’t return any value.

Please let me know if you require any further information.

  • 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-27T07:48:06+00:00Added an answer on May 27, 2026 at 7:48 am

    ok, I see two problems with the script. First, you should create the cbFunc before passing it into the getJSON. Secondly lets check if yahoo is returning it’s data by alerting when it was created. If the results is empty you’ll need help with the yahoo api more.

    // Accepts a url and a callback function to run.
    function requestCrossDomain() {
        function cbFunc(data) {
            if (data.query.created) {
                //var result = JSON.parse(data.results[0]);
                alert(data.query.created);//put a breakpoint here to check the data.results if you get it created.
            }
            else 
                throw new Error('Nothing returned from getJSON.');
        }
    
        var site = 'http://domain A/Services/A.aspx/GetString'; 
        var yql = 'http://query.yahooapis.com/v1/public/yql?q=' + encodeURIComponent('select * from html where url="' + site + '"') + '&format=json&callback=?';
    
        $.getJSON(yql, cbFunc);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page with this method in CreateTicket.aspx.cs: [WebMethod()] public static string Categories()
I have a page based web method which works fine, using [WebMethod], i.e [WebMethod]
I have a JSON response that is formatted from my C# WebMethod using the
I have a .aspx with a static method decorated with the [WebMethod] attribute and
I have a .NET webmethod that I have called from jQuery. The method returns
I'm calling a page method using a jquery function that's somewhat like this: function
I have this method: [WebMethod] public OpenAccountResult OpenAccount() { OpenAccountResult test = new OpenAccountResult(/*true*/)//the
I have some ASP.NET page and webservice WebMethod() methods that I'd like to add
I have a simple web service operation like this one: [WebMethod] public string HelloWorld()
I have ajax code for asp.net (non-mvc) to call to a webMethod to get

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.