Josh Starsick
Josh Starsick

Reputation: 43

How do I create a button within the jQueryMobile framework and have it call the URL but not do anything on the page?

How do I create a button within the jQueryMobile framework and have it call the URL on the remote server but not do anything on the page?

I have a web enabled device that accepts commands in the form of http://deviceip/index.htm?cmd=xxxx The url doesn't return any data or at least any data that I want to display. Calling the url causes the device to do something (i.e. turn a light on or off etc..) In the old days I'd create a hidden Iframe and set it as the button's target I'm pretty sure that is really the wrong way to do it.

<div class="ui-block-a"><a href="http://deviceip/index.htm?cmd=xxxx" data-role="button" data-icon="plus">On</a></div>

How do I make the above call the url but not do anything?

Upvotes: 3

Views: 98

Answers (1)

RoToRa
RoToRa

Reputation: 38390

Call the URL using ajax:

<a href="http://deviceip/index.htm?cmd=xxxx" onclick="jQuery.get(this.href); return false;" data-role="button" data-icon="plus">On</a>

Upvotes: 1

Related Questions