Avatar of steva
steva
 asked on

Controlling PHP Output

I'm working on a web page that has a div that contains a slide show.  The source of the page is a database record on the server that contains the  type of slide show, pointers to the images that will be displayed, and perhaps a half dozen other slide show parameters that the user will set through their browser by interacting with a JavaScript dialog. The idea is that the slide show parameters will be Ajaxed up to the server, the server will build the new HTML for the player div, and the new innerHTL for the player div will be Ajaxed back down.

What I'm not seeing clearly is how I can get PHP to build up the player div HTML without outputting anything automatoca;;u to the client.  That is, normally when a browser requests a PHP page, the PHP runs and whatever is left automatically shows up in the client' browser.  I don't want that.  I just want what the innHTML for one div to show up and this only because we return it in a Ajax request.

Thanks for any thought.
Steve
PHP

Avatar of undefined
Last Comment
steva

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Dave Baldwin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
steva

ASKER
Hi Ray,

There's no code yet.  I'm still walking through the whole thing in my mind.

Regarding jQuery resources, on my bookshelf I have:
   Learning jQuery 1.3 - Swedberg
    jQuery Cookbook - Various Experts
    jQuery in Action - Bibeault & Katz
    Head First jQuery - Benedetti
    jQuery Enlightmenment - Lindley
    Pro jQuery - Freeman

But my question doesn't seem to be about jQuery.  The question is how to make PHP construct just a piece of the page - the slide show div - and return that innereHTML in an Ajax response, without causing anything to display on the client's browser.  What does that PHP script look like?  I'll have no problem getting jQuery on the client page to put that innerHTML in the right place.

Steve
steva

ASKER
Dave,

This is also going to be more than one page or file of code.  You need the initial file that displays the main page.  You need a PHP page that responds to the AJAX requests and you need another page that records the user settings in the database.

Agreed.  The question now is what will the PHP script look like that responds to the Ajax request that is passing up the new slide show parameters.  How do I get that script to build the new slide show div and respond to the Ajax request with  the new innerHTML, without displaying anything on the client's browser?

Steve
steva

ASKER
Or maybe the best solution is to build the div with jQuery at the client, rather than bothering PHP, and then upload the new div innerHTML to the server later, to keep it in the loop.  Maybe this is what Ray was suggesting, but I missed it.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Ray Paseur

... return that innereHTML in an Ajax response, without causing anything to display...
Why would you want to return something that causes nothing to display?  I am not getting this concept yet, I think.
steva

ASKER
It will display when the jQuery in the client sticks the Ajax response into the DOM.  I just wanted to avoid doing something in PHP that caused the whole page to go down and get displayed, since that's what normally happens when you request a php page.  That is, you request a php page, php runs, and bang! -  the whole thing in your browser.  But I'm not issuing a browser request for a php page here, so maybe I'm worrying about nothing.

Plus, as I suggested in my last post, the better solution is probably to have jQuery process the new slide show parameters at the client and put the results directly into the div, instead of getting involved with the server at this point.
steva

ASKER
Thanks.  I probably wasn't very clear about what I was trying to do, but in my own mind I'm past the block I had, and I credit the dialog here for getting me past that.  Sometimes you just need to talk to someone.

Thanks
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Ray Paseur

Sounds like you're on the right track.  Usually jQuery can be used to just reload a part of the browser viewport, not the whole web page.
steva

ASKER
I too only wanted to load a part, but that part was the entire innerHTML of a div and I didn't know how to do that without triggering a download of the whole page.  Since I started this post I've decided I probably don't need to  have the server send me a div's html, but if I do return to that approach I discovered phpquery, that I'd never heard of before yesterday.  It apparently will build a DOM on the server for a page and pull out any part of it you want -  just what I was looking for.

Anyway, thanks for your interest.
Steve