Inserting in to MySQL database using AJAX + PHP -
I'm trying to insert data from data for non-refreshing page data, my HTML page looks like this:
pre & lt; & Lt; Top & gt; & Lt; Script src = "http://code.jquery.com/jquery-latest.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form name = "form1" method = "post" action = "" & gt; Enter name & lt; Input type = "text" name = "t1" id = "t1" & gt; & Lt; / TD & gt; & Lt; Br> Enter city & lt; Input type = "article" name = "t2" id = "t2" & gt; & Lt; / TD & gt; & Lt; Br> & Lt; Input type = "button" name = "button1" value = "insert in db" onClick = "aa ()"> & Lt; / Form & gt; & Lt; Div id = "d1" & gt; & Lt; / Div & gt; & Lt; Script type = "text / javascript" & gt; Function aa () {var xmlhttp = new XMLhttpRequest (); Xmlhttp.open ("GET", "insert.php? Name =" + document.getElementById ("t1"). Value + "& amp; City" + document.getElementById ("t2"). Value, incorrect); Xmlhttp.send (zero); Document.getElementById ("d1"). InnerHTML = xmlhttp.responseText ;; } & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt; And my insert.php looks like this:
Say browser console:
(index): 16 unwanted reference references: XMLhttpRequest is not defined (index): 16a (index): 9 onclick
Thank you very much.
ps I think my MYSQL connect is security risk, it was designed to test how it works.
(index): 16 unwanted reference references: XMLhttpRequest is not defined (index): 16 Aa (index): 9 onclick
JavaScript is case-sensitive. The function is XMLHttpRequest (with a capital H).
Comments
Post a Comment