{"id":956,"date":"2022-08-30T15:09:59","date_gmt":"2022-08-30T15:09:59","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/json-error-on-javascript-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:09:59","modified_gmt":"2022-08-30T15:09:59","slug":"json-error-on-javascript-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/json-error-on-javascript-collection-of-common-programming-errors\/","title":{"rendered":"Json error on Javascript-Collection of common programming errors"},"content":{"rendered":"<p>I need some help finding out what&#8217;s wrong in this code:<\/p>\n<pre><code>ajaxRequest.open(\"POST\", \"http:\/\/localhost:8181\/add\", true)\najaxRequest.setRequestHeader(\"Content-type\",\"application\/x-www-form-urlencoded\");\najaxRequest.send(data);\n<\/code><\/pre>\n<p>I&#8217;m trying to send data to the server using POST, and ajaxRequest is an <code>ajaxRequestElement()<\/code>.<\/p>\n<p>The problem is when I open the page, the console provided by Chrome to detect Javascript errors says <code>POST http:\/\/localhost:8181\/add undefined (undefined)<\/code>.<\/p>\n<p>I know the URL is correct and the page receiving the data is ok too, I tried this before in PHP and works fine, so I don&#8217;t understand what&#8217;s happening.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:06:29. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I need some help finding out what&#8217;s wrong in this code: ajaxRequest.open(&#8220;POST&#8221;, &#8220;http:\/\/localhost:8181\/add&#8221;, true) ajaxRequest.setRequestHeader(&#8220;Content-type&#8221;,&#8221;application\/x-www-form-urlencoded&#8221;); ajaxRequest.send(data); I&#8217;m trying to send data to the server using POST, and ajaxRequest is an ajaxRequestElement(). The problem is when I open the page, the console provided by Chrome to detect Javascript errors says POST http:\/\/localhost:8181\/add undefined (undefined). I know [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-956","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=956"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/956\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}