People who think JavaScript is not a programming language are people who's opinion on JavaScript you should not respect.
JavaScript is a language that has grown organically inspired by semantics of Scheme and syntax of Java. It's original purpose was not general but it has now grown to be so.
JavaScript as a language is suitable to do just about any task if it's fit for it. Take a look at examples like node.js where JavaScript has access to host environment consisting of IO functionality which allows it to be used for generic server side programming
My friend also advocates against using Javascript's OOP functionality, claiming that "you shouldn't be processing data, merely validating." Is Javascript really limited to validating data and making flashy graphics on a web page?
No, JavaScript is a programming language, if you want to represent data structures, algorithms and logic then use the tools the language offers. Specifically 1st class functions and prototypes are powerful tools.
He goes on to claim "you shouldn't be attempting to access databases through javascript" and also says " in general you don't want to be doing your heavy lifting in javascript". I can't say I agree with his opinion, but I'd like to get some more input on this.
Wrong, In the browser we have a database called indexedDB which we access with JavaScript. It's a database baked right into the browser and if you want to use it (and you should) then you use JavaScript.
Also note that both mongodb and couchdb allow you to use javascript to run adhoc queries on the database directly.
As for heavy lifting, he's partly correct. If your doing heavy lifting you should be doing it in C or erlang. Although note that the term "heavy lifting" is vague, for example I wouldn't encode or decode videos in JavaScript, I wouldn't do image processing in JavaScript (use C). I wouldn't no number crunching in JavaScript (use fortran).
Has Javascript evolved from the definition above to something more powerful, has the way we use it changed, or am I just plain wrong
JavaScript was written in a period of 2 weeks just to slap minor scripting functionality into HTML. Since then it has grown severely. Since ES3 (1999) it has been a powerful general purpose programming language.
First of all; I'd put some question marks on that 1% figure. How did they measure this in the first place? Most usage statistics are collected client-side, using (drum roll) javascript. Disabling javascript completely means you're not counting those users. Furthermore, most of the script-aware users use things like NoScript, which is far more sophisticated than a simple "turn all javascript off"; instead, there's a whitelist, a blacklist, and a per-case decision for the gray area. I use NoScript myself, and more often than not, I only allow those scripts on a site that it needs to function, while Analytics and other tracking sites are tossed on the blacklist. So I probably count as "javascript enabled", even though I default to "javascript off", and serving me something that looks broken until I enable Javascript makes a bad impression - enough to make me close the page within a second unless I know it has what I need.
But let's assume the 1% figure is accurate. The fact that some users browse scriptlessly isn't your biggest concern. You should also consider the following:
- Accessibility. While you can write accessible javascript, it is very hard to get it right, and you need to test on a wide array of user agents and configurations. If, however, your site is written in clear semantic HTML and functions well without Javascript enabled, it is typically easy to get accessibility right.
- SEO. Most search engine spiders don't execute Javascript, and if they do, they don't typically go all the way. So basically all content that you generate or pull in using Javascript is invisible to search engines.
- Integration with third-party tools. One of the great things about HTML is that it is a well-defined, standardized textual data format. Thousands of tools can process it to perform all sorts of tasks, and the ability to transform and accumulate your content adds value to your site. If you rely on javascript to display it, most of these tools will break.
- Security. While Javascript is not inherently insecure, moving application logic to the client has important security consequences, and it's easy to overlook issues.
- Mobile devices. Not all smartphones have the processing power to run your javascript as smoothly as you'd need it; many mobile browsers don't even support the full feature set of a desktop browser's javascript engine; and the very nature of the device (small screen, limited input devices, touch screen rather than a mouse) may break quite a few javascript / DOM features you might take for granted.
Best Answer
I realized you may be in this category. Make sure you read the Open letter to students with homework problems before making further posts. I tried to follow the rules in there for answering this, because i'm already starting to have flashbacks to CSC101.
---Original Answer---
There's a few steps you'll need to take to do this.
1) Hook onto the event that the button generates.
< button onclick="myFunction()" > Click me < /button >
2) In a function called myFunction() (within a code tag) you'll need to provide the javascript/jquery to act on the event. In this case, this is where you'll get the contents of the textbox and then provide the logic for performing the request to Ebay's API:
< code> function myFunction(){ //Provide what you want to do in response to the button click here. } < /code>
3) Complete the request and show output. Once the request is done, you'll need to use some jQuery/javascript to modify the page to show results. Most commonly, you'll have a paragraph tag or something with an id that you want to get at to modify it.