0

I am trying to make a Rest API call using Ajax (Post request). The API returns XML as response. I want to parse the response in my server side code and then pass the parsed value to client side, so that my presentation layer is not overwhelmed.

Can anyone suggest an effective way to parse the xml server side and then return the response to ajax call back function. Basically I am looking for a way to send the parsed value to my ajax call back function which would be executed when ajax status is successful.

Following is my ajax call

$('button[name=sendsms]').on("click", function(){   

                var button = $(this);
                var form = button.parents('form:first');
                var postData = form.serialize();
                var formURL = form.attr("action");              
                $.post(formURL,{ data : postData, method : "ajax" }, function (data, status, response){
                    if(status == 'success'){
                        // Access the server side parsed data here
                    }

                }, );
        });
    });
  • @Tibrogargan OP is looking for ways to parse XML on server and return output to inner Ajax's callback – Rajesh Nov 14 '16 at 07:55
  • 1
    @Tibrogargan that question has zero relevance to what OP is asking – charlietfl Nov 14 '16 at 07:56
  • Can you post your server side code? – Aruna Nov 14 '16 at 07:57
  • This sounds more like a server side question. Where exactly are you having problems? Not at all clear what you are asking or what you are trying to do with the xml...you can receive xml with $.ajax – charlietfl Nov 14 '16 at 07:57
  • Sorry, out of the three reasons this question should be closed, I picked the one the code presented seems to be asking about – Tibrogargan Nov 14 '16 at 07:59
  • Kishalay, if you're asking about how to parse XML in the server, you need to post the code used on the server and tag the question appropriately. There are far too many ways that task could be done to answer here (off topic, too broad). Your question is ambiguous, you ask about parsing XML, but then the code you post has nothing to do with that (off topic, unclear). Please clear up the question and post code relevant to what you actually need to do. – Tibrogargan Nov 14 '16 at 08:09

0 Answers0