0

I want to send the browser events that can occur, onclick,onsubmit,etc.. to a server.
How can I send the events occuring to the server?
At least sending the event and the element it occured on is fine, as i will be having the same webpage loaded in the server side and I want to try duplicate the same there.
Currently I am working on CefSharp in the server end and using JS to execute the user commands, manually, like click and all. But I want to be able to recieve from the client end and duplicate here.

Please comment if ant clarifications needs as I can refine the question further if needed. Sorry I am beginner and I dont know how to go about or what to asl for exactly :(

theCrow
  • 176
  • 3
  • 13

2 Answers2

1

As far my knowledge Ajax will not send any event to the server but yes we can write ajax call when events happen. Also in ajax we collaborate client side data and send to server side to do some server side work. Server will send either success or error based on the work done at server side. And best part of ajax is it will not reload the page.

If you elaborate your requirement may be i can suggest something else.

  • what i need is to simulate the client side actions in the server, in which I am running CefSharp to simulate a browser. So the events occurring at the client end in the browser somehow needs to be recognized and send to the server so I can do the same there. Is this clear? Or is there anything more you need? – theCrow Aug 23 '17 at 06:27
  • In that case i would suggest to write a jquery or javascript code on client side to track all clicked "ID" and save into some array means when you click on some button you get id of it and store into array. When final save write a ajax to send array. Now in server you have all ID's of elements where you clicked client side. With this id you can take a call and write your server code to do your rest job. hope fully this will help. – sarfaraj khatri Aug 23 '17 at 06:55
  • ok, this might be dumb, but not always we find ID for the elements that are clicked, if I am right in that regard, then how do you get around that? If I am wrong, can you please confirm. Also can the same be done with keypress also? – theCrow Aug 23 '17 at 07:04
  • in jQuery for key press also event is there you can write that event and update array accordingly. **About not finding ID ->** In that case u can use user define attributes and class – sarfaraj khatri Aug 23 '17 at 11:26
0

Occurring event on client side can send it to the server by AJAX. AJAX is the technology which you can send request to the server without loading a page. And you can use AJAX with help of jQuery, which is a javascript library. Thanks

Haq Nawaz
  • 412
  • 1
  • 4
  • 12
  • Can you tell me a little more? As I am pretty new, I am not sure how to go about. How do we capture the event at client end? by adding any script in the webpage loaded? And how and in which format it is shared between client and server? Really sorry to ask so much :( – theCrow Aug 23 '17 at 05:40
  • Use jQuery for client side will help you in events, selection of element etc. Study this tutorial will help you in jQuery. https://www.w3schools.com/jquery/ – Haq Nawaz Aug 23 '17 at 05:43