javascript - axios上傳數(shù)據(jù)到php返回為空
問(wèn)題描述
1.vue 2.0使用axios上傳數(shù)據(jù)返回為空,后臺(tái)為php
2.vue代碼
saveEssay(){console.log(this.titleData);this.axios({ method: ’post’, url:’XXX’, data: { title: this.titleData, tags: this.tagsData, content:this.contentData, isPublish:0 }}) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }) },
3.php代碼
<?phpheader(’Content-type:text/html;charset=utf8’); header(’Access-Control-Allow-Origin:*’); header(’Access-Control-Allow-Methods:POST’); header(’Access-Control-Allow-Headers:x-requested-with,content-type’); $mysqli=new mysqli();$mysqli->connect(’xxx’,’xxx’,’xxx’,’xxx’);if (mysqli_connect_errno($mysqli)){ echo '連接 MySQL 失敗: ';}$v1=$_REQUEST[’title’];$v2=$_REQUEST[’tags’];$v3=$_REQUEST[’content’];$v4=$_REQUEST[’isPublish’]; echo $v1.$v2.$v3.$v4?>
4.console返回?cái)?shù)據(jù)
![圖片描述][1]
5.備注get獲取數(shù)據(jù)是有效的,post提交數(shù)據(jù)不知為何在php頁(yè)面數(shù)據(jù)獲取不到,返回為空,html頁(yè)面可以訪問(wèn)到,也可以插入到數(shù)據(jù)庫(kù),只不過(guò)為空,而且 使用jQuery單純上傳數(shù)據(jù)到php是可以的,這兩者只差在了上傳數(shù)據(jù)的方法上。求大神解答
問(wèn)題解答
回答1:file_get_contents('php://input')
回答2:自行百度,php獲取不到j(luò)son格式的數(shù)據(jù)
相關(guān)文章:
1. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””2. boot2docker無(wú)法啟動(dòng)3. docker-compose中volumes的問(wèn)題4. nignx - docker內(nèi)nginx 80端口被占用5. java - SSH框架中寫分頁(yè)時(shí)service層中不能注入分頁(yè)類6. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.7. dockerfile - 為什么docker容器啟動(dòng)不了?8. docker容器呢SSH為什么連不通呢?9. 關(guān)于docker下的nginx壓力測(cè)試10. docker images顯示的鏡像過(guò)多,狗眼被亮瞎了,怎么辦?

網(wǎng)公網(wǎng)安備