asp.net - Call JSON wcf service via jQuery -


I have json according to the json WCF methods from the aspx page with questions according to the questions.

This is my test method:

  [Public Service Interface] WebMessageBodyStyle.Wrapped, UriTemplate = "Test")] for response & lt; String & gt; testing(); } [AspNetCompatibilityRequirements (RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] Public Category EParcelServiceImpl: IEParcelService {Public Response & lt; String & gt; Test () {Return WebServiceHelper.Execute ((= => "Test Message"); }}   

This service is posted on IIS. When I call this method from chrome: everything is fine and I can see the result but when I call it from jquery, there is an error in: nETWORK_ERR: XMLHttpRequest exception 101. I try to find a solution in Google . But the result was not successful, how can I solve it?

jQuery Call:

  & lt; Script language = "javascript" & gt; $ () Ready (click on function () {$ ("# myButt") (function () {$ .ajax ({cache: .. false, async: false, type: "gET", url: "http : // local host / EParselService / EParcelServiceImpl.svc / test ", contentType:" application / json ", datatype:" json ", success: function (data, textStatus) {warning ('success called callback'); warning Data;; Warning (textStatus);}, Error: Function (XMLHttpRequest, textStatus, errorThrown) {Warning ('errorCallBack'); Warning ('textStatus =' + textStatus + '/ nerrorThrown =' + errorThrown);} }); Warning ('done!');});}); & Lt; / Script & gt; & Lt; Input type = "button" value = "get value from server" id = "mybutt" />    

So this is a common issue (see)

The resource for an XMLHttpRequest should be on the same page as this page is requesting it. This is to prevent XSS (see) ants. If you want to use a resource from a different domain then you have to use something like jsonp (see) how to do this with a WCF for a good tutorial.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -