Re: Extra Data in POST response

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 12/02/2023 19:49, John Iliffe wrote:
I seem to be getting extraneous data in the response sent to the browser by PHP.

The server query is an AJAX request in json format which is received and
processed correctly and the result is sent using the "echo" function.  I have
checked and the area where the response is constructed is empty when processing
starts.

The data received by the browser has BOTH the request json data followed by the
correct response in the received string (result not HTML, just a string that
will eventually be converted to json but so far will only be caught in the
browser for display).

I'm using XMLHttpObject in the browser and I haven't been able to find a way to
separate the request from the response.  Before I construct an elegant
workaround does POST normally return the request?  If not, what am I doing
wrong?  So far I have always used GET so I know it doesn't return the request.

For completeness, here is what the server says it is sending to the browser
(using echo) (The json may be wrong; I'm still just trying to receive it).

------
sent to browser:
"jres":[{"item_id":"5","i_type":"OL","i_name":"Student Success
Pages","i_stock":"99924","i_price":"14.00","i_books_box":"0"},{"item_id":"13","i
_type":"CD","i_name":"Basic Instructors Guide 9th
Ed.","i_stock":"9983","i_price":"19.95","i_books_box":"0"},{"item_id":"20","i_ty
pe":"SG","i_name":"Canadian Amateur Radio Basic Qualification Study
Guide","i_stock":"274","i_price":"44.95","i_books_box":"20"},{"item_id":"21","i_
type":"SG","i_name":"Canadian Amateur Radio Advanced Qualification Study
Guide","i_stock":"1586","i_price":"49.95","i_books_box":"16"}]
-----

here is the original request from the browser, as decoded by server
------
request method: POST
requests: array (
   'req' => '{"func":"act","item":"438"}',
)

json last error message: No error
decoded_args:
    func=act
    item=438

-------

and here is what the browser says it received back:

-----
  received:-->array(2) {
   ["func"]=>
   string(3) "act"
   ["item"]=>
   string(3) "438"
}

"jres":[{"item_id":"5","i_type":"OL","i_name":"Student Success
Pages","i_stock":"99924","i_price":"14.00","i_books_box":"0"},{"item_id":"13","i
_type":"CD","i_name":"Basic Instructors Guide 9th
Ed.","i_stock":"9983","i_price":"19.95","i_books_box":"0"},{"item_id":"20","i_ty
pe":"SG","i_name":"Canadian Amateur Radio Basic Qualification Study
Guide","i_stock":"274","i_price":"44.95","i_books_box":"20"},{"item_id":"21","i_
type":"SG","i_name":"Canadian Amateur Radio Advanced Qualification Study
Guide","i_stock":"1586","i_price":"49.95","i_books_box":"16"}]<--
-----

Thanks in advance for any suggestions you can give.

John
======

Hi John,

What does your PHP code look like? Something in it must be outputting the request, as that's not something that would just occur all by itself.

Regards,
Ash

--
www.ashleysheridan.co.uk



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux