0

I have an web service running on http://remoteip:8080/TestService I want to call it through java script this service takes parameters in JSON format {"status":"F","subscriber":[{"PhoneNumber": 1234567890}, {"PhoneNumber":0123456789}]} like this how can I implement this in javascript.

1 Answer 1

1
<script>
function callWebService() {

            jQuery.ajax({
                url: 'http://remoteip:8080/TestService',
                type: "POST",
                data: {
                    "status": "F",
                    "PhoneNumber":"0123456789",
                    .....
                    .....
                },
                dataType: 'json',
                success: function (data) {
                    console.dir(data);
                },
                error: function (xhr, err) {
                    alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
                    alert("responseText: "+xhr.responseText);
                },
                complete: function () {
                }
            });      
    }

</script>

Hope it helps you

Sign up to request clarification or add additional context in comments.

6 Comments

Second parameter expects array of phone numbers can you help me with this?
Create array of phone numbers and pass array object to "PhoneNumber": phoneNumberArray
can you help me with syntax
var phoneNumbers = [1234567890, 0123456789]; var phoneNumbersJson = JSON.stringify(phoneNumbers); data:{ PhoneNumber: phoneNumbersJson }
var phoneNumbers = [1234567890, 0123456789]; var phoneNumbersJson = JSON.stringify(phoneNumbers); url: 'http://104.155.141.228:8080/updatesubscriber_status', type: "POST", data: { "status": "F", "PhoneNumber":"phoneNumbersJson" }, Is this correct
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.