79142407

Date: 2024-10-30 18:40:49
Score: 0.5
Natty:
Report link

Finally this is how i managed to fix it: I am a calling a C# method here in MVC. Make sure your C# method is not declared as static. Just like this. Also i spend probably 8 hours day trying to understand why i could not get any results back. You need the async = false option. Otherwise you will spend similar amount of time if not more!

C# public string CreateCoordinatesFromPostcode(string postcode) { // logic string result = "XXXXXX" // your logic return result; }

JavaScript
 let result = '';
 $.ajax({
     type: "POST",
     url: '/clib/CreateCoordinatesFromPostcode',
     async: false,
     data: { postcode: postcode },
     success: function (response) {
         result = response;
     },
     error: function (error) {
         console.error(error);
     }
 });

 console.log("just after  /clib/createCoordinatesFromPostcode");

 return result;
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: PanLondon