rest POST request is giving unkown error?

ThienHieu

New Member
I'm sending a REST POST request from javascript using jQuery ajax to eXist db.In eXist db i have created a collection with the name "test" and now i'm taking inputs from html page and converting them to an XML after that sending an XML through POST request.Here is my sample code\[code\]<HTML><body> <script type="text/javascript" src="http://stackoverflow.com/questions/jquery-1.7.2.js"></script><script type="text/javascript" >function OnSubmitForm(){ var Ip = document.myForm.ip.value; var Type = document.myForm.type.value;if(!((Ip=="" )|| (Ip==null))){ var re = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; var stringText="<?xml version='1.0' encoding='utf-8'?> "; stringText+="\n<Configuration>\n<IP>"+Ip+"</IP>"; stringText+="\n<Type>"+Type+"</Type>\n</Configuration>"; var url = "http://localhost/exist/rest//db/test/"; var ajax = new XMLHttpRequest(); jQuery.support.cors = true; $.ajax({ url: url , async: false, type: 'POST', contentType: "application/xml", username: 'admin', password:'' , data: stringText, success: function(msg) { alert(msg); }, error: function(request, msg, error) { alert(error); } }); return true; }};</script><form name="myForm" onsubmit="return OnSubmitForm();"><table cellspacing="2" cellpadding="2" border="1"> <tr> <td align="right">IP or IP's</td> <td><input type="text" name="ip" /></td> </tr> <tr> <td align="right">Type</td> <td><input type="text" name="type" /></td> </tr> <tr> <td align="right"></td> <td><input type="submit" value="http://stackoverflow.com/questions/10683729/Submit" /></td> </tr> </table></form></body></HTML>\[/code\]But if im submitting the form its giving error like"Unknown+XML+root+element%3A+Configuration"What is this error? how can i store this xml in db?Please answer.Thanks in advance.
 
Back
Top