This is a migrated thread and some comments may be shown as answers.

Ajax call is not working - Collect Information from merchant transaction page

1 Answer 75 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
ABC
Top achievements
Rank 1
ABC asked on 22 Mar 2018, 06:16 PM

I am new to Ajax. I want to retrieve the transaction details from the merchant website after payment processing. My ajax call script is not working. Please help.

C# Method:

public class RetrieveCache{[WebMethod]public string RetrieveTransactionData(string ID){

ChannelFactory<ServiceSoap> PayChannelFactory = new ChannelFactory<ServiceSoap>("ServiceSoap12");

ServiceSoap Paychannel = PayChannelFactory.CreateChannel();

XmlNode node = Paychannel.RetrieveCachedData(ID);return node.InnerXml;

}}

 

Ajax call Script in HTML Page to call the above c# method

 

Html Page URL: http://localhost:55014/SuccessPage.html?id=29473740923

 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript">

</script><script type="text/javascript"> $(document).ready(function () {

var url = window.location.search; debugger;var token = (url.replace("?", "").split("=")[1]).toString(); debugger;var dataval = JSON.stringify({ token: token }); $.ajax({ url: "http://localhost:55014/RetrieveCache.cs/RetrieveTransactionData", type: 'post', data: JSON.stringify({ token: token }), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function(data){ alert(data);}, error: function (err) { alert(err)}});});

</script>

This is the error message in console: localhost:55014/RetrieveCache.cs/RetrieveTransactionData 404 (Not Found)

1 Answer, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
Iron
answered on 20 Jan 2023, 02:39 PM
You've got a propagation problem. the first $1 (document). ready adds event listeners to page components. The element and its listener vanish if the page is updated in place and are replaced by a new element without a listener.

The event needs to be broadcast up the page lifecycle using a listener that needs to be attached to an element.
Tags
Ajax
Asked by
ABC
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Iron
Share this question
or