ajax POST to MS Webservice
Hi,
i have a problem.
I have an ajax call to a webservice, and it works.
Now I try to set parameters, and it donsn't work anymore.
I try it with parameters in data and without.
The Webservice will only be called, if the webservice has no parameters.
I have testet the webservice in the visual studio (2005), and it works.
Can anyone help me?
$("input.ajaxbtnPlanAdminFreigabe").click(function(){
$.ajax({
type: "POST"
,contentType: "application/json; charset=utf-8"
,url: "WebService/vpt_status.asmx/PlanAdminFreigabe"
,data: "{'PcTreeID':'4711','ProduktID':'1004'}"
//,data: "{}"
,dataType: "XML"
//,cache: false
,async: false
//,beforeSend:
//,dataFilter:
,error: function(returnXML) {
$(returnXML).find('ERROR').each(function(){
alert($(this).text());
}); //close each(
} //close success
,success:
function(returnXML) {
$(returnXML).find('SUCCESS').each(function(){
alert($(this).text());
}); //close each(
} //close success
//,complete: function(returnXML){alert(returnXML.text());}
});
});
[WebMethod]
public XmlDocument PlanAdminFreigabe(string PcTreeID, string ProduktID)
{
XmlDocument xmlDoc = new XmlDocument();
XmlNode myRoot, myNode;
myRoot = xmlDoc.CreateElement("XML");
xmlDoc.AppendChild(myRoot);
try
{
// Update PlanFreigabe
DbController db = new DbController();
db.updatePlanFreigabeAdmin(int.Parse(PcTreeID), int.Parse(ProduktID));
myNode = xmlDoc.CreateElement("SUCCESS");
myNode.InnerText = "Admin Freigabe ausgeführt.";
myRoot.AppendChild(myNode);
}
catch(Exception)
{
myNode = xmlDoc.CreateElement("ERROR");
myNode.InnerText = "Es ist ein Fehler aufgetreten.";
myRoot.AppendChild(myNode);
}
return xmlDoc;
}