Click here to Skip to main content
15,886,078 members

Cross Domain WebService Call in Asp.net using Jquery

Aditya Magotra asked:

Open original thread
Hi,

Requirement is:
a) webservice(Suppose Webservice.asmx) is hosted on one server, suppose www.xyz.com
b) On www.xyz.com domain, a javascript file is present who accesses this webservice.
c) On www.test.com , the javascript file of www.xyz.com is included in html page.
d) When i run html page of www.test.com site, i got jquery parsed error.
e) When i include same javascript file in html page of www.xyz.com domain then it works fine.
f) Both applications are running on IIS6.0

I implemented it using using jquery with jsonp.

var baseurl = "http://localhost:50249/WebService.asmx";
$.support.cors = true;

    $.ajax({
        type: 'POST',
        //crossDomain: true,
        dataType: "jsonp",
        jsonpCallback: 'jsonCallback',
        contentType: "application/json; charset=utf-8",
        url: baseurl + "/HelloWorld",
        data: '{}',
        dataType: "json",
        success: function(data) {
            alert(data.d);
        },
        error: function(err) {
            alert(err.statusText);
        }
    });


Getting statusText="No Transport".
status=0

Following Error in browser console.
"Origin http://localhost:64048 is not allowed by Access-Control-Allow-Origin. "


Note: In IE8 it is working fine.

Can anyone please let me know how to access cross domain webservice ?

Thanks in Advance.
Tags: jQuery, IIS 6.0, IIS, ASP.NET2.0, Webservice

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900