I need to get data at my application from other domain. I'm tring to use jsonp but every time I have error '80020101'
Here is my code (ASP.NET MVC 4) at 'other domain'
public ActionResult Test() { return Json(new { foo = "bar", baz = "Blech" }, JsonRequestBehavior.AllowGet); } public string Test2() { return "aaa"; }
And here is my ajax method what sends a request
$.ajax({ url: 'https://192.168.0.61/CryptoProTestTool/Home/Test2/', type: 'GET', dataType: 'jsonp', error: function(xhr, status, error) { alert("error"); }, success: function(json) { alert("success"); } });
What's wrong? Why do I always have an error in this simple example? I have issue with Test and Test2 data...
Manual testing shows that service sends data
EDIT 1: I have an error "Can not finish action. error 80020101." at error function of ajax request.I tried to change Test2 like this
public ActionResult Test2(){ return Content("<script language='javascript' type='text/javascript'>alert('Hello world!');</script>"); }
But have the same issue
Edit2:Hi again!I was told working solution but after I run it issue appears.
public ActionResult Test2() { return Content("MyMethod('test12345');"); }
And Javascript code:
function onPageLoad() { CheckCryptoProAvailable();}function CheckCryptoProAvailable() { $.ajax({ url: 'https://192.168.0.61/CryptoProTestTool/Home/Test2/', type: 'GET', dataType: "jsonp", error: function(xhr, status, error) { alert("error = "+ error.toString()); }, success: function(json) { } });}function MyMethod(testValue){ alert(testValue);}
Everything goes ok and MyMethod is called after request. But after it I see a window from ajax request error handler. What's wrong again?