Hi how to send data to server .i have written a code in javascript which will get data from server and then send it to server.How to make use of the xmlhttpreq.
[CODE] <html> <head> </head> <body> <script type="text/javascript"> function createRequest() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer 6+ try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { // Internet Explorer 5 try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } return xmlHttp; } function add100(p) { var reqObj = createRequest(); reqObj.onreadystatechange=function() { if(reqObj.readyState==4) { //callback } } var url="add.php?p="+p+"&sid="+Math.random(); reqObj.open("GET",url,true); reqObj.send(null); } </script> <a href="#" onclick="add100(this.value);">Link 1</a> </body> </html> [/CODE]
[CODE] $.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); } }); [/CODE]
Help @senthilarumugam spread the word by sharing this article on Twitter...