Ajax call to Web Method results in 500 error but when moved to another directory works.
I created a dumb-ed down version of my program that makes a web method call from AJAX. Both the Ajax call and the web method are contained within the same aspx file. When this aspx file is placed in a certain directory it works. If I move it to another directory it fails. There are no relative links or anything that I can find that would break if the code is moved. In the Event Viewer I get the error unknown web method. In the browser debug I get the 500 Internal Server Error message.
$.ajax({ type: "POST", url: "TestPaypal.aspx/ReceivePaymentInfo", contentType: "application/json; charset=utf-8", datatype: "json", async: false, cache: false, data: JSON.stringify(transactionInfo), success: function (succ) { if (result.hasOwnProperty("d")) { console.log('Success: ', result.d); window.alert("Thank you!"); } else { console.log('Success: ', result); } }, error: function (err) { console.log(JSON.stringify(err)); window.alert("Error call 555-1212 for assistance."); } });
[WebMethod(EnableSession = true)] public static string ReceivePaymentInfo(string amount, string parentPaymentId, string payerStatus, string paymentDate, string paymentId, string saleId, string status ) { if (status.ToLower() != "approved") { return "Not approved"; } return "Approved"; }
Aucun commentaire:
Enregistrer un commentaire