jQuery的Ajax请求通过SSL [英] jQuery Ajax request over SSL
问题描述
所以,我现在用的是下面的code发送Ajax请求
So I am using the following code to send an ajax request
$.ajax({
type: 'POST',
url: base_url + "/notifications/send_notification",
dataType: 'json',
data: {
action: 'action_complete',
entity_id: 31
}
});
这code完美的作品在我的本地机器上,但是当我把它上传到我们的服务器(现在有SSL设置),并尝试做它通过https,而不是HTTP,就来了一个500内部服务器错误。
This code works perfectly on my local machine, but when I upload it to our server (which now has SSL setup), and try doing it over https and not http, it comes up with a "500 Internal Server Error".
诗的BASE_URL变量不包括https开头的网址。
P.s the "base_url" variable does include the "https" url.
编辑: 这是在Chrome网络>标题标签的截图:
Here is a screenshot of the Network > Header tab in Chrome:
推荐答案
如果 BASE_URL
是你在网站上,我的意思是,如果你输入你的网站<一HREF =https://www.example.com相对=nofollow> https://www.example.com 和 BASE_URL
是 https://www.example.com/notifications/send_notification 然后尝试省略 BASE_URL
从网址
参数。
If base_url
is the website you're in, I mean if you enter your website in https://www.example.com, and base_url
is at https://www.example.com/notifications/send_notification then try to omit base_url
from the url
parameter.
如果 BASE_URL
是另外一个网站,那么它可能是一些跨站点脚本问题。
If base_url
is another site then it might be some cross-site script issue.
如果非上述的那么它可能是一个问题的服务器。你确定SSL证书是好的?如果是自签名的,那么你需要在批准在浏览器中第一位。
If non of the above then it might be an issue with the server. Are you sure the SSL certificate is good? If it's self-signed then you need to "approve" it in the browser first.
最后,您可以检查的准确发送/接收数据的IE浏览器,只是F12和检查网络
(必须是开放提出要求之前)。
Lastly, you can check the exact send/receive data with i.e Chrome, just F12 and check Network
(must be open before the request is made).
此外,你可以直接请求的URL与小提琴手(如果它的职位,如果是GET然后简单地进入它与浏览器)。
Additionally, you could directly request that url with Fiddler (if it's POST, if it's GET then simply get into it with a browser).
这篇关于jQuery的Ajax请求通过SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!