javascript - Ajax跨域请求和表单提交事件
假设现在有两家网站,A和B,他们面向同一用户(C)提供服务。
现在,C登录A公司提供的网页,在登录表单中输入用户名和密码。
在输入用户名的时候,浏览器异步请求数据,表单下方实时显示可用用户名,该数据是B网站服务器返回的(A并没有B网站服务器的控制权)。
然后输入完成以后,按回车,触发表单提交事件。提交的时候,用户名发送到A网站,密码本地哈希后发送到B网站。
以上怎么实现,不需要讲的太具体。
回复内容:
假设现在有两家网站,A和B,他们面向同一用户(C)提供服务。
现在,C登录A公司提供的网页,在登录表单中输入用户名和密码。
在输入用户名的时候,浏览器异步请求数据,表单下方实时显示可用用户名,该数据是B网站服务器返回的(A并没有B网站服务器的控制权)。
然后输入完成以后,按回车,触发表单提交事件。提交的时候,用户名发送到A网站,密码本地哈希后发送到B网站。
以上怎么实现,不需要讲的太具体。
可以使用如下两种做法:
使用CORS (Cross-origin resource sharing)
需要B网站请求返回的头部添加CORS相关Header,其中Access-Control-Allow-Origin中添加A网站的域。具体跨域信息参考:http://blog.csdn.net/qgw_2000/article/details/8882051通过A网站代理发送请求到B网站
请求都发给A网站,针对需要请求B网站的请求进行转发,在nginx中,简单通过proxy_pass就可以做到。
这不就是xss
嘛,B服务器设定一下,接受来自A域名的跨域请求就可以了。
如果懂服务器配置建议采用二楼的第二种方法,如果不懂,用php的curl同样可以实现,前端表单异步提交都给A站,A站通过curl访问B站的接口(或者说模拟提交表单)来获取你想要的数据

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

Golang is better than Python in terms of performance and scalability. 1) Golang's compilation-type characteristics and efficient concurrency model make it perform well in high concurrency scenarios. 2) Python, as an interpreted language, executes slowly, but can optimize performance through tools such as Cython.

Python is easier to learn and use, while C is more powerful but complex. 1. Python syntax is concise and suitable for beginners. Dynamic typing and automatic memory management make it easy to use, but may cause runtime errors. 2.C provides low-level control and advanced features, suitable for high-performance applications, but has a high learning threshold and requires manual memory and type safety management.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

Using HTML to render components and data in React can be achieved through the following steps: Using JSX syntax: React uses JSX syntax to embed HTML structures into JavaScript code, and operates the DOM after compilation. Components are combined with HTML: React components pass data through props and dynamically generate HTML content, such as. Data flow management: React's data flow is one-way, passed from the parent component to the child component, ensuring that the data flow is controllable, such as App components passing name to Greeting. Basic usage example: Use map function to render a list, you need to add a key attribute, such as rendering a fruit list. Advanced usage example: Use the useState hook to manage state and implement dynamics

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

There is no difference between HTML5 and H5, which is the abbreviation of HTML5. 1.HTML5 is the fifth version of HTML, which enhances the multimedia and interactive functions of web pages. 2.H5 is often used to refer to HTML5-based mobile web pages or applications, and is suitable for various mobile devices.

Golangisidealforbuildingscalablesystemsduetoitsefficiencyandconcurrency,whilePythonexcelsinquickscriptinganddataanalysisduetoitssimplicityandvastecosystem.Golang'sdesignencouragesclean,readablecodeanditsgoroutinesenableefficientconcurrentoperations,t
