<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
<script>
$.get("http://example.com/", function(data) {
alert(data);
});
</script>
Run Code Online (Sandbox Code Playgroud)
它对该URL执行OPTIONS请求,然后从不使用任何内容调用回调.
当它不是跨域时,它工作正常.
不应该只是jQuery与一个<script>节点进行调用,然后在加载时进行回调吗?我明白我无法得到结果(因为它是跨域的),但那没关系; 我只是希望电话通过.这是一个错误,还是我做错了什么?
我总是得到"你要求的证书无效." 但我需要有一个公共端点专门"查看"操作,每个人都可以访问whitout发送访问令牌并保持其他操作与令牌验证
这是我的Api控制器的一部分:
/**
* @inheritdoc
*/
public function behaviors()
{
return [
'contentNegotiator' => [
'class' => ContentNegotiator::className(),
'formats' => [
'application/json' => Response::FORMAT_JSON,
//'application/xml' => Response::FORMAT_XML,
],
],
'verbFilter' => [
'class' => VerbFilter::className(),
'actions' => $this->verbs(),
],
'access' => [
'class' => AccessControl::className(),
'only' => ['view'],
'rules' => [
[
'actions' => ['view'],
'allow' => true,
'roles' => ['?'],
],
],
],
'authenticator' => [
'class' => CompositeAuth::className(),
'authMethods' => [
HttpBasicAuth::className(),
HttpBearerAuth::className(),
QueryParamAuth::className(),
],
],
'rateLimiter' …Run Code Online (Sandbox Code Playgroud)