Skip to content
Advertisement

PHP http code 0 unable to read custom headers

I have a php script which is being called in an angular project. I always get the response code as 0. I can find the request headers in chrome debugging section, but when i see in script it a always empty. Also the php script is called twice with request method ‘options’ and ‘get’. Iam not able to proceed further to get the details. Iam working on a windows , PHP7,iis server.

JavaScript

Advertisement

Answer

You can use to call custom headers as an array

JavaScript

Refer : https://stackoverflow.com/a/11709337/11298876, this answer was really helpful. Now you can use headers array to call each header (Note it will be in camel case)

JavaScript

to get the actual headers.

Then finally you can use an array_push(because you have used it in your script) like this

JavaScript

to send the headers.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement