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

VamsiKrishna
  • 751
  • 6
  • 14
  • 29

1 Answers1

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);  
    }
austin
  • 1,171
  • 1
  • 13
  • 32