如何使用post提交json数据 如何使用php的post提交json数据... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不知道我有没理解错,希望帮到你form表单中的submit改成buttonJS中做以下三步:1.中先获取你需要的内容2.把数据打包成json格式3.form.submit() 我也想知道,一般来说都是用form提交字段的吧。 以下是一个例子,你可以按需扩展。$post_data = array( 'name'=>'aaa', 'age'=>45, ); $url='http://www.example.com/example.php'; $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result=curl_exec($ch); echo $result; a.php$data = array("name" => "testname", "age" => "25");$data_string = json_encode($data);$ch = curl_init('http://localhost/test/a.php');curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));$data = curl_exec($ch); print_r($data);b.php1.echo file_get_contents("php://input");2.echo $GLOBALS["HTTP_RAW_POST_DATA"];1或2均可获取到由a.php页面传过来的json数据 json就是字符串,大的字符串用post小的用get方式不就可以了。 软件完工 关于传递值IF的问题. 各位帮个忙:dedecms伪静态 一个接收问题。。一个支付宝的。。。收不到值。帮忙看看 多虑的我再请教高手一个给客户做网站的问题。 SELECT框的选择问题 如何做个合理的队列 dedecms 我怎么才能判断这个区域拖动的那一个标签? 织梦安装后卸载问题,请求帮助 求解zend加密 怎么在post结果页打印出数据来源页网址?
form表单中的submit改成button
JS中做以下三步:
1.中先获取你需要的内容
2.把数据打包成json格式
3.form.submit()
$post_data =
array(
'name'=>'aaa',
'age'=>45,
);
$url='http://www.example.com/example.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($ch);
echo $result;
$data = array("name" => "testname", "age" => "25");
$data_string = json_encode($data);$ch = curl_init('http://localhost/test/a.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string)));
$data = curl_exec($ch); print_r($data);b.php
1.echo file_get_contents("php://input");
2.echo $GLOBALS["HTTP_RAW_POST_DATA"];1或2均可获取到由a.php页面传过来的json数据