63d8975ceb8076b7a7e349abc189289ce337e747
[yaffs-website] / vendor / jcalderonzumba / gastonjs / docs / api / commands / javascript / execute.md
1 execute
2 =========
3 Command to execute javascript code within the current page you are browsing.
4
5 ##Example of use
6 ####Request
7 ```json
8 {
9     "name": "execute",
10     "args": [
11         "(function () {\n  document.getElementById(\"element_1\").value = \"THIS_IS_SPARTA\";\n  document.getElementById(\"element_3\").selectedIndex = 1;\n})();\n"
12     ]
13 }
14 ```
15 ####Response
16 If there are no javascript errors then the response should be:
17 ```json
18 {
19     "response": true
20 }
21 ```
22 ##Rule of thumb for javascript code
23 As a recommendation try always to make your code like this:
24 ```javascript
25 (function () {
26   //Here should go all the code you want to execute
27 })();
28 ```