我想从我的Web 应用程序中在客户端 localhost 上 POST 一些 JSON 数据。>
我尝试使用 localhost ,但这是指服务器端- Localhost 。我也尝试使用 Javascript 代替 PHP ,但是效果不佳。
我要实现的目标是能够将数据发送到客户端 localhost ,其他桌面应用程序将在该客户端上侦听特定端口,然后执行一些工作(就像打印标签一样)。
我尝试的代码:
(我将XAMPP用作 localhost 测试服务器)
$.ajax({
type: 'post',
url: 'localhost',
dataType: 'json',
data: 'json',
success: function(json) { ... },
error: function(error) { ... }
});
答案 0 :(得分:0)
您是指本地专用网络中的服务器和客户端吗?如果是这样,您可以在发送发布请求时仅指定客户端的IP地址和端口。
例如:
$.ajax({
type: 'post',
url: '192.168.xxx.xxx:8080',
dataType: 'json',
data: 'json',
success: function(json) { ... },
error: function(error) { ... }
});