Looking to place a button that triggers a simple SMS script on my Tropo account using jQuery and an Ajax get request. The button does not need to open anything, but simply trigger the Tropo script (JS) to send an SMS.
The URL with token given on Tropo is: http://api.tropo.com/1.0/sessions?action=create&token=foo
The about URL when triggered send an SMS saying: "Dinner's ready".
I have a button in html: Dinner
In my HTML I'm linked to an external js:
$("#myButton").click( function(e) {
e.preventDefault();
$.get("http://api.tropo.com/1.0/sessions?action=create&token=foo", function( data ) {
console.log( data );
});
});
This does not succeed, and does not fire any console errors. Would love some insight.
I think you are trying to get data from a cross-domain service, according to same origin policy you can't do so. You can try like this:
$("#myButton").click( function(e) {
e.preventDefault();
$.ajax({
url: 'http://api.tropo.com/1.0/sessions?action=create&token=foo',
dataType: 'jsonp',
success: function(data) {
console.log( data );
}
});
});