且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Netflix如何在没有页面刷新的情况下提交评分,而且没有JavaScript?

更新时间:2022-10-16 10:17:30

After a little more research, I found the answer I was looking for. You can do this by sending an HTTP response 204 status code from the page you are sending your request to. For instance, assuming you're sending it to a php script, start the page with this:

header("HTTP/1.0 204 No Response");

As stated here: http://php.net/manual/en/function.header.php#32569

If you haven't used, HTTP Response 204 can be very convenient. 204 tells the server to immediately terminate this request. This is helpful if you want a javascript (or similar) client-side function to execute a server-side function without refreshing or changing the current webpage. Great for updating database, setting global variables, etc.

This is what I'm now using in my scripts.