-1

I am looking for a way to pass data from Vue to PHP. So currently I am receiving a JSON object using a PHP query. It looks like:

<?php echo getBhQuery('search','JobOrder','isOpen:true','id,title,categories,dateAdded,externalCategoryID,employmentType,customText12', null, 200, '-dateAdded');?>

I also have inputs in my Vue app where I want to send data to that PHP query when the user uses the input. From there I want to rerun that PHP query with the added data.

I can filter the JSON object directly adding something to the PHP query to filter it like so:

<?php echo getBhQuery('search','JobOrder','isOpen:true AND customText12:"Chicago Region"','id,title,categories,dateAdded,externalCategoryID,employmentType,customText12'); ?>

So by adding 'AND customText12:"Chicago Region"' I would only get a JSON object with items that have their region set to Chicago Region. I'm just not sure the correct way in Vue to pass data to this PHP query and then rerun that query without refreshing the page. I assume I would need to use ajax or Axios or something like that, but so far I have not had any luck doing this with them and haven't found much online in the way of doing this in Vue.

TLDR: How to pass data from Vue to PHP in a fashion like Ajax.

3
  • What do you mean I want to send data to that PHP query ? That doesn't make any sense. Commented Nov 7, 2018 at 20:03
  • @IsaacVidrine I want to post data from my Vue app to PHP using something like Axios or Ajax. And am having troubles getting either to work. Commented Nov 7, 2018 at 20:55
  • Look at this stackoverflow.com/questions/6782230/… Commented Nov 8, 2018 at 8:04

1 Answer 1

1

You will need to post data using Axios to post to a PHP page or an API built from PHP (like Laravel).

Sign up to request clarification or add additional context in comments.

1 Comment

Do you know of any good tutorial on how to do this with Axios? I was trying to do this earlier before I posted here and I kept running into issues and couldn't find how to resolve them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.