通过javascript向手机发送消息

Send message to mobile through javascript

本文关键字:消息 手机 javascript 通过      更新时间:2023-09-26

我是javascript新手,我想用javascript向移动设备发送消息在PHP中,这可以通过以下代码来完成

$number = 'your-number';
$url = "http://pointsms.in/API/sms.php?username=[xxxxxx]&password=[xxxxxx]&from=[xxxxxxxx]&to=[xxxxxxxxxx]&msg=[xxxx]&type=1&dnd_check=0";
fopen($url, 'r');

但我正在使用opencart,我想使用javascript 执行此操作

在javascript中,我使用window.location在window中打开url但我不想在窗口打开

window.location.replace('http://pointsms.in/API/sms.php?username=[xxxxxx]&password=[xxxxxx]&from=[xxxxxxxx]&to=[xxxxxxxxxx]&msg=[xxxx]&type=1&dnd_check=0');

请帮助解决此问题

尝试使用AJAX。

点击此处阅读更多信息:http://www.w3schools.com/ajax/ajax_examples.asp

AJAX
var xhr = new XMLHttpRequest()
xhr.open('GET', 'http://pointsms.in/API/sms.php?username=[xxxxxx]&password=[xxxxxx]&from=[xxxxxxxx]&to=[xxxxxxxxxx]&msg=[xxxx]&type=1&dnd_check=0', true)
xhr.send()