Controller is firing but I can't get the $_GET |
I changed over to POST and added
xhr.setRequestHeader("Content-type", "application/json"); xhr.setRequestHeader("X-Requested-With",'xmlhttprequest'); Now, I am getting this error: [Sun Mar 25 11:57:47.099508 2018] [:error] [pid 13272:tid 1652] [client ::1:56672] PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0 Any ideas? I am also getting: background.js:85 POST http://localhost/Subit_backend/register%....com%22%7D 400 (Bad Request)
proof that an old dog can learn new tricks
Here are the headers. Maybe you can see something obvious? BTW, when I send just the email, it seems to give me a status 200. So there is something wrong with the payload?
Request Headers: POST /Subit_backend/register%7B%22lat%22:41.058304899999996,%22long%22:-74.0711244,%22email%22:%[email protected]%22%7D HTTP/1.1 Host: localhost Connection: keep-alive Content-Length: 74 Pragma: no-cache Cache-Control: no-cache Origin: chrome-extension://bdjgnodlhfmhghjhbkkkaaammfocdpib X-Requested-With: xmlhttprequest User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36 Content-type: application/json Accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9 Cookie: ciNav=no; XDEBUG_SESSION=PHPSTORM; cisession=t387m0rtvof1rmpoell1m3uakebg97l9 Request Payload: {lat: 41.058304899999996, long: -74.0711244, email: "[email protected]"} : "[email protected]" lat : 41.058304899999996 long : -74.0711244 Response Headers: HTTP/1.1 400 Bad Request Date: Sun, 25 Mar 2018 22:03:59 GMT Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.28 X-Powered-By: PHP/5.6.28 Content-Length: 1134 Connection: close Content-Type: text/html; charset=UTF-8
proof that an old dog can learn new tricks
You are still trying to send it in the url. Please check my code again and update accordingly.
Hooray!I finally got the message from the client back to the server with POST! Thank you! Back on the client, you have:
xhr.onload = function () { //response will go here // Request finished. Do processing here. }; question: 1) once I build the response on the server, how do I send it back to the client? 2) I realize the onload will fire, but how do I get access to the buffer response on the client?
proof that an old dog can learn new tricks
Here's how you do it.
References: https://developer.mozilla.org/en-US/docs...ng_Started https://zqzhang.github.io/blog/2016/04/1...-ajax.html https://www.w3schools.com/xml/ajax_xmlht...create.asp https://www.w3schools.com/js/js_json_parse.asp https://www.codeigniter.com/user_guide/l...ntent_type PHP Code: <?php Code: <script type="text/javascript"> |
Welcome Guest, Not a member yet? Register Sign In |