How can I access request headers in liquid?

Highlighted
Tourist
4 0 1

I need to pass some piece of information to my .liquid pages (via an ajax request). I'm currently trying to use a custom HTTP request header to do this. I could also use a POST form parameter. However when trying to POST to the URL I get a 404 error. Meanwhile a GET works fine for the same URL. It seems like you have not implemented the POST then. So, I am instead trying to use an HTTP request header. I can see that I have successfully inserted it via the browser debug console. But I for the life of me cannot figure out how to read the header in my server-side .liquid code. Can anyone tell me how to do this? Or if its not doable, ANY way that I can pass a custom data parameter that my .liquid server code is able to read? 

Thanks,
A very frustrated developer

1 Like
Highlighted

in liquid you can't use server side script because liquid is templating language not server side language 

Shopify theme developer and customization

I Would like to add new functionality or customize an existing one, please hire me.
If helpful then please Like and Accept Solution .
Email: ashiquehussaincodediary@gmail.com

1 Like
Highlighted
Tourist
4 0 1

Okay, well I need to load a page differently depending on where in my code its being called from. so then, I need to specify in an ajax call which template to use yes? how do I do that?

0 Likes
Highlighted
Tourist
4 0 1

Bump. I just want to skip loading the header if I do the load from an ajax call. Do I need a separate template for this? how do i specify that in my ajax call?

thanks

0 Likes
Highlighted
Shopify Partner
3 0 1

Hi have similar case.

I want to create a page that receives POST data from other application and show some content.

0 Likes