How might a C# programmer approach writing a solution in javascript?
Posted
by Ben McCormack
on Stack Overflow
See other posts from Stack Overflow
or by Ben McCormack
Published on 2010-05-12T14:42:12Z
Indexed on
2010/05/12
15:04 UTC
Read the original article
Hit count: 218
UPDATE: Perhaps this wasn't clear from my original post, but I'm mainly interested in knowing a best practice for how to structure javascript code while building a solution, not simply learning how to use APIs (though that is certainly important).
I need to add functionality to a web site and our team has decided to approach the solution using a web service that receives a call from a JSON-formatted AJAX request from within the web site. The web service has been created and works great. Now I have been tasked with writing the javascript/html side of the solution.
If I were solving this problem in C#, I would create separate classes for formatting the request, handling the AJAX request/response, parsing the response, and finally inserting the response somehow into the DOM. I would build properties and methods appropriately into each class, doing my best to separate functionality and structure where appropriate.
However, I have to solve this problem in javascript. Firstly, how could I approach my solution in javascript in the way I would approach it from C# as described above? Or more importantly, what's a better way to approach structuring code in javascript?
Any advice or links to helpful material on the web would be greatly appreciated.
NOTE: Though perhaps not immediately relevant to this question, it may be worth noting that we will be using jQuery in our solution.
© Stack Overflow or respective owner