Calling #PHP on #JSP / #Java Pages with Javascript – #js
Jul.18, 2009 in
JAVA/JSP, Javascript, PHP, Programming, Tweaks, jQuery
Working with hacked together management systems that utilize both Java/JSP and PHP can be extremely annoying. However, jQuery has made our lives a lot easier by letting us call PHP using Javascript.
Most of us are script kiddies. Admit it, we like to build our own tools but whenever a shortcut comes into play, we take the high road. Can you really blame developers for choosing this route when time seems to always be a factor on the Internet. The issue is this leaves us with VERY hacky systems. We piece together and integrate but there are just things we can’t control. Particularly if we ever end up with anything that’s not open source.
Here’s a trick for pulling PHP into a JSP run page, or really any page for that matter, as long as it supposed Javascript. Generally speaking, all things support Javascript.
Here's how this works. jQuery we should all know. If you don't, go do some reading. It's a big deal.
$.get is from jQuery and it will pull the information over and display it.
#posthere is key. The
Most of us are script kiddies. Admit it, we like to build our own tools but whenever a shortcut comes into play, we take the high road. Can you really blame developers for choosing this route when time seems to always be a factor on the Internet. The issue is this leaves us with VERY hacky systems. We piece together and integrate but there are just things we can’t control. Particularly if we ever end up with anything that’s not open source.Here’s a trick for pulling PHP into a JSP run page, or really any page for that matter, as long as it supposed Javascript. Generally speaking, all things support Javascript.
| Javascript | | copy code | | ? |
| 1 | |
| 2 | <script src="jquery.js"></script> |
| 3 | <script type="text/javascript">// <![CDATA[ |
| 4 | |
| 5 | $.get("/location/to/file.php", function(data) {
|
| 6 | $("#posthere").html(data);
|
| 7 | }); |
| 8 | // ]]></script> |
| 9 |
Here's how this works. jQuery we should all know. If you don't, go do some reading. It's a big deal.$.get is from jQuery and it will pull the information over and display it.
#posthere is key. The
is where what you want to load will show up.
Pretty much from this point you're set. All you need to do is build the PHP file and everything will load up on the JSP pages. Remember, this can applied to any page that supports jQuery or Javascript.
Pretty much from this point you're set. All you need to do is build the PHP file and everything will load up on the JSP pages. Remember, this can applied to any page that supports jQuery or Javascript.



















































October 24th, 2009 at 6:57 AM I have a nice joke for you people!