Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ajax的跨域问题 #48

Closed
kiner-tang opened this issue Mar 19, 2015 · 9 comments
Closed

ajax的跨域问题 #48

kiner-tang opened this issue Mar 19, 2015 · 9 comments

Comments

@kiner-tang
Copy link

请问除了jsonp方式解决跨域问题之外,还有别的方式可以解决吗?mmrequest中有没有提供其他方式解决跨域问题

@RubyLouvre
Copy link
Owner

@IndexXuan
Copy link

请问mmRequest有像jquery一样的设置headers的方法或者属性吗?有空能告知一下吗,貌似没在文档里看见啊。。。谢谢

@RubyLouvre
Copy link
Owner

jquery怎么设置,它就是怎么设置

@IndexXuan
Copy link

擦汗。。。 正妹老师百忙中都回复了,为啥不明说。试了headers{}, requestHeaders{}, beforeSend时设置,貌似都不行。或者怎么取到原始xhr对象,我直接自己设置也好啊。您能看看吗? 感谢!

@RubyLouvre
Copy link
Owner

avalon.ajax({/**/}).setResponseHeader("xx","yy")

avalon.get(a,b,c).setResponseHeader("xx","yy")

avalon.post(a,b,c).setResponseHeader("xx","yy")

get, post, getJSON,ajax方法都会返回promise对象,上面有一个setResponseHeader方法

@IndexXuan
Copy link

感谢回答。不过应该是发送请求前设置xhr.setRequestHeader(‘ ’, ‘ ’),应该怎么设置。有没有或者怎么实现像ng一样的$http服务,能全局拦截或者捕获所有的请求(来设置header或者处理回应的错误),对spa很有用。能提供个思路吗。以前真的很少前端注意header。。。

@liufuhu
Copy link

liufuhu commented Oct 20, 2015

为什么不把ajax放到avalon.js里? 这是框架很基础的功能,为什么要分离开呢?

@RubyLouvre
Copy link
Owner

因为很多时候是与JQ一起使用,直接用JQ的就行了

@liufuhu
Copy link

liufuhu commented Nov 22, 2015

ths

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants