0

I have a rest webservice which can accept a string. I want to pass a json object as a string to this service. I have to use a HTML page with some textfields and has to pass the form data to the service. can any one help??

Thankyou

1

1 Answer 1

1

you can try this

 function callWebService{  
        var field= document.getElementById('field').value; 
        //use jquery to convert to json object
        //see comment for more info on this

        var ws = 'http://localhost:8080/WebServicePath/';  
        var url = ws + field;  

        var xmlhttp = null;  
        if (window.XMLHttpRequest) {  
            xmlhttp = new XMLHttpRequest();  
        }  
        else if (window.ActiveXObject) {  
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");  
        }  

        xmlhttp.onreadystatechange = function() {  
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {  
            alert("Success");  
        }  
        else {  
            alert("Failure");  
        }  
        };  
        xmlhttp.open('GET', url, true);  
        xmlhttp.send(null);  
    }
Sign up to request clarification or add additional context in comments.

3 Comments

can u help if the method to be used is POST

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.