Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Cant Post JSON To Web Service

$
0
0

Hi, I have been reading through the Q+A of other members trying there solutions but none of them are working for me. I have a button event when clicked i wish to get the values from the text fields on the mobile client and post them to the web service url here i keep getting 'error sending data' - what am i missing something on the servlet API side? thanks for your help

button.addEventListener('click', function(e) {
 
    var params = {
        "places" : {
            Country : textCountry.getValue(),
            Capital : textCapital.getValue()            
        }
    };
 
    var xhr = Ti.Network.createHTTPClient({});
 
    // function to deal with errors
    xhr.onerror = function() {
        Ti.API.info('error, HTTP status = ' + this.status);
        alert('Error Sending Data');
    };
 
    //set enconding
    xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8");
 
    xhr.open("POST", 'http://130.206.127.43:8080/Test');
    xhr.send({
        "places" : JSON.stringify(params)
    });
});

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>