Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/441.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Vue.js Axios post发送空值_Javascript_Php_Vue.js - Fatal编程技术网

Javascript Vue.js Axios post发送空值

Javascript Vue.js Axios post发送空值,javascript,php,vue.js,Javascript,Php,Vue.js,我正在努力解决使用axios的问题 Vue文件: <script> export default { name: 'npcs-list', data () { return { data: '', index: '', dialogues: '', input: { npc_name: '', }, npc_id: '', npc_name: '', npc

我正在努力解决使用axios的问题

Vue文件:

<script>
export default {
  name: 'npcs-list',
  data () {
    return {
      data: '',
      index: '',
      dialogues: '',
      input: {
        npc_name: '',
      },
      npc_id: '',
      npc_name: '',
      npc_start_dialogues:'',
      dialogues: [],
      fields: [{
        name: 'id',
        callback: 'stringToInt'
      },
      {
        name: 'name'
      },
      {
        name: 'start_dialog'
      },
      {
        name: 'actions', // <----
        title: 'Akcje',
        titleClass: 'center aligned',
        dataClass: 'center aligned'

      }
      ],
      css: {
        pagination: {
          wrapperClass: 'pagination pull-right',
          activeClass: 'btn-primary',
          disabledClass: 'disabled',
          pageClass: 'btn btn-border',
          linkClass: 'btn btn-border',
          icons: {
            first: '',
            prev: '',
            next: '',
            last: ''

          }

        }
      }
    }
  },
  components: {
    Vuetable,
    VuetablePagination,
    VuetablePaginationInfo
  },
  methods: {
    insertNPC () {
      const data = this
      if (this.input.npc_name != '' && this.npc_start_dialogues != '') {
        axios.post('http://localhost/test/Quests/endpoints/insert.npc.php', {
          npc_name: 'dupa',
          npc_startdialog: 'dupa2'
        })
          .then((response) => {
            data.status = response.data
          })
          .catch(function (error) {
            console.log(error)
          })
        if (data.status == '1') {
          alert('Działa!')
        } else {
          alert('Taki tag już istnieje!')
        }
      } else {
        alert('Brak wystarczającej ilości danych')
      }
    },
    showModal(data) {
      this.$refs.myModalRef.show()
      this.data = data,
      this.npc_id = data.id,
      this.npc_name = data.name,
      this.npc_start_dialogues = data.start_dialog.split(";")
    },
    hideModal () {
      this.$refs.myModalRef.hide()
    },
    onHidden (evt){
      this.npc_id = '',
      this.npc_name = '',
      this.npc_start_dialogues = ''
    },
    log (data) {
      console.log(data)
    },
    editDialogue (data) {
      this.$router.push({
        name: 'editDialogues',
        params: {
          id: data
        }
      })
    },
    editOption (data) {
      this.$router.push({
        name: 'editOptions',
        params: {
          id: data
        }
      })
    },
}
</script>
但作为回应(xdebug日志):


C:\xampp\htdocs\test\Quests\endpoints\insert.npc.php:12:
对象(stdClass)[1]
公共“npc_name”=字符串“dupa”(长度=4)
公共“npc\U startdialog”=字符串“dupa2”(长度=5)
我将感谢任何帮助,也欢迎任何提示。文字限制太难了

<?php

header('Content-Type:  text/html');

include_once '../Checkers/CheckIfNPCExists.php';
include_once '../Inserts/InsertNPC.php';

$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody);
$status = new CheckIfNPCExists();

var_dump($data);

$result = $status->uniqueTest($data->npc_name);
if($result == '0'){
  $npc_class = new InsertNPC();
  $npc_result = $npc_class->createNew($data->npc_name,$data->npc_startdialog);
  echo $npc_result;
}
object(stdClass)[1]
  public 'npc_name' 
<pre class='xdebug-var-dump' dir='ltr'>
<small>C:\xampp\htdocs\test\Quests\endpoints\insert.npc.php:12:</small>
<b>object</b>(<i>stdClass</i>)[<i>1</i>]
  <i>public</i> 'npc_name' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'dupa'</font> <i>(length=4)</i>
  <i>public</i> 'npc_startdialog' <font color='#888a85'>=&gt;</font> <small>string</small> <font color='#cc0000'>'dupa2'</font> <i>(length=5)</i>
</pre>