0

Now I am working on a project in which I send X-Request-Id header to browser client. And now I want browser client side send this field back to my server side. How could I implement this?

As now, I know If-Modified-Since, Cookie will be sent back to server side automatically. Does http has a way to define custom field which follows this rule?

P.S. I do not mean keep this field when a page has been refreshed or jump to another page. I use ajax request to get data from server side, my project is a SPA. The purpose of mine is to log a user's action with one unique dentifying.

frustigor
  • 307
  • 3
  • 7
  • Possible duplicate of [Adding http request header to a a href link](https://stackoverflow.com/questions/15835783/adding-http-request-header-to-a-a-href-link) – Ned Howley Aug 01 '17 at 09:07
  • I am using ajax request. I do not think this is a solution. – frustigor Aug 01 '17 at 09:15
  • In that case I would edit your question to narrow down your situation, this will help you get better answers! – Ned Howley Aug 01 '17 at 09:19

1 Answers1

0

You could POST data back to an endpoint on your server. You could use form submission or AJAX depending on what you are after. https://www.w3schools.com/html/html_forms.asp

Ryan
  • 506
  • 2
  • 15
  • In fact, I want client side send this field back to server automaticlly everytime a new ajax request sent. And a way I can think up is add it to my ajax request headers, but lots of code will be changed if this way. – frustigor Aug 01 '17 at 09:11
  • 1
    You should probably elaborate on your original question. This might possibly help you achieve what you are after ... https://stackoverflow.com/questions/20356374/add-custom-http-header-to-all-jquery-ajax-requests – Ryan Aug 01 '17 at 09:17
  • Thanks you @Ryan, this answer gives me some idea. – frustigor Aug 01 '17 at 09:25