我似乎无法用我的jsonp电话打我的网络方法......我做错了什么?相反,我得到以下错误..请参阅下面的方法
XMLHttpRequest无法加载http://askia.service.local/AskiaService.asmx/Login。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许原点“http://askia.web.local”访问。
网络服务电话
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public User Login(string username, string password)
{
User userLoggedIn;
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
{
throw new Exception("username or/and password is not supplied");
}
try
{
var dataAccess = new DataAccess(ConnectionString);
userLoggedIn = new User(dataAccess.Login(username, password));
}
catch (Exception exception)
{
throw exception;
}
return userLoggedIn;
}
JSONP
function AddTaskList(taskListTitle) {
var jsonDataObject = JSON.stringify({
'username': 'username',
'password': 'password'
});
$.ajax({
url: "http://askia.service.local/AskiaService.asmx/Login",
contentType: "application/json; charset=utf-8",
type: "POST",
dataType: "json",
data: jsonDataObject,
success: function (response) {
console.log(response);
}
});
alert('task list added');
}