alexgeorg86
alexgeorg86

Reputation: 145

Store content of jquery load() function into a variable

I want the content of my load() function to be stored into a variable so to pass it into another function. The project is to pass it as a sting to a function that creates a toast message in a webview for android phones! My code is :

$( '#lightson' ).click( function () {
            $.get( 'http://<?php echo $_SESSION['ip']?>/?2', {}, callbacka() );
            function callbacka() {

                var ua = navigator.userAgent.toLowerCase();
                var isAndroid = ua.indexOf("android") > -1;

                if(isAndroid) {

                Android.showToast("**Here I want to put my content**");

                }
                    else {

                        $('.status2').load('status2.php').delay(3000).queue(function() {
                        $('.status2').empty().dequeue();
                        });

                    }
            }
    } ); 

Can anyone help?

Upvotes: 0

Views: 424

Answers (1)

Naftali
Naftali

Reputation: 146302

AHHHH!

You are running your callback immediately! Remove the ():

$.get( 'http://<?php echo $_SESSION['ip']?>/?2', {}, callbacka );

Upvotes: 1

Related Questions