{"id":5056,"date":"2022-10-07T19:04:13","date_gmt":"2022-10-07T17:04:13","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=5056"},"modified":"2022-10-08T11:57:41","modified_gmt":"2022-10-08T09:57:41","slug":"tinyhttp-a-simple-form-using-ajax","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/","title":{"rendered":"TinyHttp &#8211; A simple Html Form &#038; Using Ajax"},"content":{"rendered":"<p>Today I was playing around with my <a href=\"https:\/\/github.com\/pschatzmann\/TinyHttp\">TinyHttp<\/a> project: I was investigating how I can drive multiple parameters of a guitar effects sketch by using a web dialog.<\/p>\n<p>To provide some information via html is simple. It gets a little bit more complicated if we want to support <strong>Html Forms<\/strong>, so I decided to extend the project a bit and provide some <strong>examples<\/strong>.<\/p>\n<h2>A Simple Form Example<\/h2>\n<p>Here is the <a href=\"https:\/\/github.com\/pschatzmann\/TinyHttp\/blob\/main\/examples\/httpForm\/httpForm.ino\">link to the source code<\/a> .<\/p>\n<p>The logic is quite simple: We implement the methods that<\/p>\n<ul>\n<li><strong>provide the html<\/strong> with the form with the actual values<\/li>\n<li><strong>handle the post<\/strong> of the new value.<\/li>\n<\/ul>\n<p>and finally we just need to define when these methods are called. If you look at the example source code, it is <strong>quite easy<\/strong> to understand.<\/p>\n<h2>Ajax: Using Json<\/h2>\n<p>Modern web applications usually communicate with <strong>webservices<\/strong> by getting the information as <strong>JSON<\/strong> and posting JSON data back to update the information in the application.<br \/>\nHere is the <a href=\"https:\/\/github.com\/pschatzmann\/TinyHttp\/blob\/main\/examples\/webservice\/webservice-html\/webservice-html.ino\">link to the source code<\/a>.<\/p>\n<p>The logic is a little bit more involved: We implement the methods that<\/p>\n<ul>\n<li>provide the <strong>html form<\/strong> with the actual values\n<ul>\n<li>Javascript to update the form parameters<\/li>\n<li>Javascript to post the updated form as JSON<\/li>\n<\/ul>\n<\/li>\n<li>provide the <strong>web service<\/strong>\n<ul>\n<li>Get: provide data as JSON<\/li>\n<li>Post: update values for posted JSON<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>The json serialization and deserialization is done with the help of <a href=\"https:\/\/arduinojson.org\/\">ArduinoJson<\/a>.<br \/>\nI also added the necessary CORS headers, so that we can call the service from a <a href=\"https:\/\/github.com\/pschatzmann\/TinyHttp\/blob\/main\/examples\/webservice\/webservice-html\/index.html\">local html file which is stored on your disk<\/a>. You will just need to update the ip address!<\/p>\n<p>In a nutshell &#8211; I am quite happy about the functionality that I can provide with my project&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I was playing around with my TinyHttp project: I was investigating how I can drive multiple parameters of a guitar effects sketch by using a web dialog. To provide some information via html is simple. It gets a little bit more complicated if we want to support Html Forms, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5061,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20],"tags":[37],"class_list":["post-5056","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","tag-tinyhttp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>TinyHttp - A simple Html Form &amp; Using Ajax - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TinyHttp - A simple Html Form &amp; Using Ajax - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"Today I was playing around with my TinyHttp project: I was investigating how I can drive multiple parameters of a guitar effects sketch by using a web dialog. To provide some information via html is simple. It gets a little bit more complicated if we want to support Html Forms, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-07T17:04:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-08T09:57:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/10\/httpserver.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"225\" \/>\n\t<meta property=\"og:image:height\" content=\"225\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"TinyHttp &#8211; A simple Html Form &#038; Using Ajax\",\"datePublished\":\"2022-10-07T17:04:13+00:00\",\"dateModified\":\"2022-10-08T09:57:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/\"},\"wordCount\":286,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/httpserver.jpeg\",\"keywords\":[\"TinyHttp\"],\"articleSection\":[\"Arduino\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/\",\"name\":\"TinyHttp - A simple Html Form & Using Ajax - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/httpserver.jpeg\",\"datePublished\":\"2022-10-07T17:04:13+00:00\",\"dateModified\":\"2022-10-08T09:57:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/httpserver.jpeg\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/10\\\/httpserver.jpeg\",\"width\":225,\"height\":225},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2022\\\/10\\\/07\\\/tinyhttp-a-simple-form-using-ajax\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"TinyHttp &#8211; A simple Html Form &#038; Using Ajax\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TinyHttp - A simple Html Form & Using Ajax - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/","og_locale":"en_US","og_type":"article","og_title":"TinyHttp - A simple Html Form & Using Ajax - Phil Schatzmann","og_description":"Today I was playing around with my TinyHttp project: I was investigating how I can drive multiple parameters of a guitar effects sketch by using a web dialog. To provide some information via html is simple. It gets a little bit more complicated if we want to support Html Forms, [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/","og_site_name":"Phil Schatzmann","article_published_time":"2022-10-07T17:04:13+00:00","article_modified_time":"2022-10-08T09:57:41+00:00","og_image":[{"width":225,"height":225,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/10\/httpserver.jpeg","type":"image\/jpeg"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"TinyHttp &#8211; A simple Html Form &#038; Using Ajax","datePublished":"2022-10-07T17:04:13+00:00","dateModified":"2022-10-08T09:57:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/"},"wordCount":286,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/10\/httpserver.jpeg","keywords":["TinyHttp"],"articleSection":["Arduino"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/","url":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/","name":"TinyHttp - A simple Html Form & Using Ajax - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/10\/httpserver.jpeg","datePublished":"2022-10-07T17:04:13+00:00","dateModified":"2022-10-08T09:57:41+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/10\/httpserver.jpeg","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/10\/httpserver.jpeg","width":225,"height":225},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2022\/10\/07\/tinyhttp-a-simple-form-using-ajax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"TinyHttp &#8211; A simple Html Form &#038; Using Ajax"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5056","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=5056"}],"version-history":[{"count":19,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5056\/revisions"}],"predecessor-version":[{"id":5076,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/5056\/revisions\/5076"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/5061"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=5056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=5056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=5056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}