PHP jquery data passing to object

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?..

Answers


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.


Need Your Help

Confirmation Modal in AngularJS

javascript angularjs

I have an app that manages subscriptions.

camera overlay view - just for preview?

iphone camera overlay uiimagepickercontroller

I've noticed that in OS 3.1 you can add an overlay view to the image picker with

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.