Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8956257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:44:59+00:00 2026-06-15T14:44:59+00:00

I have a button and when I click button,I will operate send a HTTPClient

  • 0

I have a button and when I click button,I will operate send a HTTPClient request..If success,i will change background image of button and set enabled= false ..If not success, don’t change.How can I do?
I used a variable and based on it but not success.
This is my code of HTTP Client

var added;
var url ="http://192.168.1.14/add/";
button.addEventListenner('click',function(e){
   add(url);
   if(added==1)
   {
        //set background for button 
   }
   else
   {
      //don't set background
   }
});
function add(url)
{
var client = Ti.Network.createHTTPClient({
enableKeepAlive : true,
onload : function(e) {
  added=1;
  Ti.API.info('Load success');
  Ti.API.info('Status:'+this.status);
},
onerror : function(e) {
  added=0;
  alert(L('cant_connect'));
},
timeout : 10000 // in milliseconds
});

client.open("GET",url);
client.send();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:45:00+00:00Added an answer on June 15, 2026 at 2:45 pm

    change your button background in function add(url).

    onload : function(e) {added=1;Ti.API.info('Loadsuccess');Ti.API.info('Status:'+this.status);//set background for button },
    

    in case your callback returns an error the button background will remain same. This is because its asyn call. Once you call the function add(url) it will send the httpclient a request. The code next to this call will be executed and when the http call returns nothing will happened to you button’s backgraound.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 4 tabs in my iphone application. When user will click a button
I currently have a simple form that when you click the save button will
I need to create a reset button which on click will set all select
I have a button click event that will fire a swing worker thread which
I have two buttons, which the user can click and will open a FileDiagloag
I have a button click event handler with a switch case in it that
I have a button click on which i have to call a webmethod and
I have a button click event that takes information from controls and enters it
I have one issue with UInavigationcontroller In my firstview i have button.If i click
I have a UINavigationController. On the right top i have a button on click

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.