1

Can someone please explain to me how the data passed to jquery object, so it's then accessible from jquery.

I.E.:

PHP script:

// $isrc variable is added by me to existing grid..
    $isrc = isrc();
    $grid->isrc = $isrc;
    $grid->load();

object declared in js:

$.fn.loadGrid = function(user_opts) {
        return this.each(function() {

            // setup DEFAULT options
            var opts = $.extend({
                order_by : "",          // sql order by
                .....
            },user_opts);
            var $grid = $(this);
            ..some stuff to do....
        });
    }
    ... some additional function to call....
});

so how do i access $isrc data? calling it after:

        var $grid = $(this);
        var isrc = $grid.data().isrc;

comes back as unidentified...

sorry i'm quite new to object oriented programming, although i did study Java and VB few years ago..

or at lease give me a link to a tutorial re subject?..

1 Answer 1

1

You have to pass the value from PHP to jQuery then do whatever you want with it. You want to echo the value in php (Ideally in a JSON format). Then use jQuery $.ajax to call the page, get the data and then do whatever you want with it in javascript.

Here are some easy to follow Video tutorials for PHP & jQuery. It covers EVERYTHING from the basics to more advanced concepts including OOP.

Best of all.. They are FREE!

http://thenewboston.org/list.php?cat=11 <-- PHP Tutorials (200 Part Series) http://thenewboston.org/list.php?cat=32 <-- jQuery Tutorials (200 Part Series)

If you go over these and learn from them. You will be able to do almost ANYTHING with PHP & jQuery.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for replying! data is passed from php to jquery as - echo json_encode($grid->data); - i can access native grid data, but not the one i added manually - that's what i need. i will have a look at the tutorials you suggested - thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.