Click here to Skip to main content
12,889,448 members (50,825 online)
Rate this:
Please Sign up or sign in to vote.
See more: Javascript jQuery HTML5
I am trying to call a web service from a local file ( HTML5 + Javascript/JQuery).

due to "Same origin policy" i am unable to send request.

i want to enable for only this page .
Posted 17-Sep-12 23:40pm
ParthaDinda 18-Sep-12 5:46am
can you post some code what ever you tried?
Kartheek.chakrala 18-Sep-12 6:19am
from html
$('#btn_test').click(function () {
type: "POST",
url: "http://localhost:5739/asmxservicestestservice.asmx/HelloWorld",
data: '{ "text": "Kartheek"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
error: OnError


function OnSuccess(data, status) {

function OnError(msg) {
alert('error = ' + msg.d);


and my web service which is running on http://localhost:5739

[WebMethod ]
[ScriptMethod( ResponseFormat = ResponseFormat.Json)]
public string HelloWorld(string text)
return "Hello World" + text;
ryanb31 18-Sep-12 7:53am
It's a browser setting, right? You'll have to change your browser or use a console app you write or something.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

One solution to your problem would be to use JSONP instead of JSON.

Here is an excellent CP article on it,

JSON to JSONP: Bypass Same-Origin Policy[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 18 Sep 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100