http 11ajax.co,javascript - "Mixed content blocked" when running an HTTP AJAX operation in an HTTPS ...

博客讲述了在提交表单到CRM系统时遇到的混合内容错误,由于API只支持HTTP而页面加载为HTTPS。作者通过创建一个PHP文件,使用CURL在服务器端提交数据到API并成功绕过浏览器的安全限制,同时实现将用户重定向到感谢页面。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I've a form which I'm submitting (through GET as it is required this way) to a crm (ViciDial). I can successfully submit the form however if I do that the processing file at crm will just echo a success text and that's it.

Instead of that text, I want to display a thank-you page on my website, so I decided to use AJAX to submit the form and redirect it to the page I need, however I'm getting this error on my browser:

Mixed Content: The page at 'https://page.com' was loaded over HTTPS,

but requested an insecure XMLHttpRequest endpoint

'http://XX.XXX.XX.XXX/vicidial/non_agent_api.php?queries=query=data'.

This request has been blocked; the content must be served over HTTPS.

This is my AJAX script:

SubmitFormClickToCall = function(){

jQuery.ajax({

url: "http://XX.XXX.XX.XX/vicidial/non_agent_api.php",

data : jQuery("#form-click-to-call").serialize(),

type : "GET",

processData: false,

contentType: false,

success: function(data){

window.location.href = "https://www.example.com/thank-you";

}

});

}

Just setting https in the URL won't work, is there any way in which I can submit the data via GET and redirect the user to my thankyou page?

============================

Problem here was mixed content, this means that I loaded a page through HTTPS and was trying to hit via AJAX an API that was in HTTP. But the browser wont allow us to just do that.

So if you can't set the API to be HTTPS (this was my case) we can still approach this in a different way.

The Main Problem was not the mixed content issue it was that I wanted to submit data to an API and redirect the users to a fancy thank you page. Instead of using AJAX, i made a php file that receives the data sends it using curl to the API (as this is being done server side there is no mixed content issue) and redirects my happy user to a fancy thank you page.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值