java or jquery script to run a php script saved as a seperate .php file on server

Posted on 2009-12-22
Last Modified: 2013-11-10

I am working with a server side scripting language that does not allow php to be used directly in conjunction with the server side templates, so to work around it, I am hoping that there is a way that I can through Java, call the PHP script which will be saved as a separate PHP file on my web server, which I believe should work around the problem. Im assuming this is possible in javascript or jquery if that would be easier. Anyways, I installed wordpress on a subdomain on my site, so basically I am trying to import blog posts from word press into my main home page template which is managed through the server side scripting form. Hopefully that makes sense.

Anyways Im including the php code from the wordpress import so basically lets assume the wordpress code im posting is saved as "wordpressNews.php" on my webserver.





$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');

foreach ($posts as $post) : start_wp(); ?>

<?php the_date(); echo "<br />"; ?>

<?php the_title(); ?>    

<?php the_excerpt(); ?> 




Open in new window

Question by:lexusgs430
    1 Comment
    LVL 16

    Accepted Solution

    You could certainly use jQuery to load up the RSS feed from wordpress, parse it, and add it to the page.  Here's an example from something I've used in the past, which will put a place holder (blogFeed) onto the page and then fill it with the results that Wordpress returns.

    <script type="text/javascript">
      $(document).ready(function() {
        $.get('/path/to/wordpressNews.php', function(resp) {
          $(resp).find('item').each(function() {
            var i = $(this);
            var title = i.find('title').text();
            var desc = i.find('description').text();
            $('#blogFeed').append('<h2>' + title + '</h2>');
            $('#blogFeed').append('<p>' + desc + '</p>');
    <div id="blogFeed">
      <p>Please wait while content is loaded...</p>

    Open in new window


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
    Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now