Jump to content

Recommended Posts

Posted

Hello,

I'm trying to submit a form through AngularJs $http object, but I can't get any response.

My post values are a json object: {"user":"johndoe", "email":"jd@..."}

But in the receiving page, I'm using this code [at no avail]:

var_dump($input->post) // WireInputData (size=0)
echo $_SERVER['HTTP_X_REQUESTED_WITH'] // returns void
echo 'hi' // works 
var_dump(json_decode($input->post, true)); // returns null
echo $config->ajax; // no response

Thanks for any help

Posted

Can you show the code you use to make the AJAX call? To access PW you will want to create a page that uses a template in which the ajax request is handled. The request is sent to said page (perhaps /ajax/ or something), not just to the template file.

edit: I missed that $input→post returns a WireInputData, so ProcessWire seems to be there. It’s probably still something to do with the request, although I don’t know Angular. Surely it’s not a GET?

Posted

Thanks Jan,

sort of figured it out: instead of using $http.post('url', data) I used a config object:

var config = {
	method: 'POST', 
	url: '/ajaxprocessingpage/',
	data: $.param({dati: jsobject}),
	headers: {'Content-type': 'application/x-www-form-urlencoded'}
}

$http(config)
  .then()...

In this case, It is accessed on the ajaxProcessingPage as an array using $input->post->dati

So complicated... !

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...