Log in

View Full Version : Help Combining PHP and Jquery



Jim Weinberg
04-18-2014, 01:06 PM
I'm putting together a page that has both PHP and Jquery code. I can get the PHP code or the Jquery code to work, but not both. Before I post the code, I just want to know if I can have a page (.php) with PHP, Jquery and HTML code in it.

Thanks.

jscheuer1
04-18-2014, 01:38 PM
Yes, that's no problem. I suppose it could be done various ways. What I usually do is start with the HTML and jQuery, then add PHP. HTML and jQuery are relatively easy because they're more or less WYSIWYG. The HTML you can see in the browser. Any problems with jQuery should appear in the browser's console (F12 in most browsers). Once they're working, you will be substituting PHP for parts of the HTML and/or jQuery (or I suppose the PHP part can be separate, but I think you mean to use it as part of the other code). Once you add the PHP, you can use the browser's "View Source" to see how the PHP is being interpreted. Look at the "View Source" before you add the PHP. Use that as a reference as to how it should look. Between that and any PHP errors you see in the source view, you can troubleshoot the code if needed.

BTW, you've already done this. That slideshow has PHP, jQuery and HTML on it.

Beverleyh
04-18-2014, 01:40 PM
Short and sweet - Yes. :)

Please post your code so we can help with the formatting/placement/structure (or whatever it is that is causing you problems)

Jim Weinberg
04-18-2014, 04:14 PM
John.

Thanks for the tips. Turns out that one of the jquery libraries wasn't loading correctly. Recopied it to the server and all works fine. Thanks.

Jim