ajax call to php

52 views
Skip to first unread message

brettmc...@gmail.com

unread,
Jan 6, 2016, 4:15:34 PM1/6/16
to ozoneplatform-users
All,

I have been struggling to send an ajax command using jQuery, to run a php file. If i download a normal distribution of Apache, it works fine. However, when I send the same call using the variant in OWF, it just sends garbage back.

AJAX Call:

            var request = $.ajax({
                url: "test.php",
                type: "POST",
                dataType: "html",
                success: function(data){
                    $("#php").html(data);
                }
            });

PHP (test.php):

<?php
while ($personCount < 10) {
    $result .= "<b> {$personCount} people </b>";
    $personCount++;
}

echo $result;
?>


The response I get is:

{$personCount} people "; $personCount++; } echo $result; ?>


Has anyone had this issue? I'm not a php developer so any help is greatly appreciated.

Brett

Ross Pokorny

unread,
Jan 7, 2016, 9:31:17 AM1/7/16
to ozoneplat...@googlegroups.com
Brett

Are you saying that you are trying to run PHP code in the Apache Tomcat
server? Tomcat is a Java servlet container that can't generally run PHP,
though you could manage to run it using some third-party components as
detailed here: http://stackoverflow.com/questions/779246/run-a-php-app-using-tomcat .

Unless you've done something similar to what is described in that link, I
would not expect PHP to run at all in a Tomcat server. Typically PHP is run
using other types of web servers, such as Apache HTTPD.

Ross Pokorny

brettmc...@gmail.com

unread,
Jan 7, 2016, 9:58:26 AM1/7/16
to ozoneplatform-users
Hi, Ross.

Yes, that is what I was saying. I hadn't realized Tomcat wasn't generally running php. My goal is two-fold: 
1. I need to access a MySQL database and query data
2. I need to run shell scripts on the server so I can interact with compiled Fortran code. 

Any advice?

Thanks!

Ross Pokorny

unread,
Jan 7, 2016, 10:07:36 AM1/7/16
to ozoneplat...@googlegroups.com
At a high level, your options would be:

1. Set up a separate server to run your PHP code.

2. Write servlets to handle your needs instead of PHP. The servlets would be
written in Java or another language that compiles to JVM bytecode. It sounds
like your needs are pretty straightforward and the Java platform is certainly
capable of facilitating them.

3. Hack PHP support into Tomcat as described in the post I linked or possibly
through some other mechanism. I don't really recommend this path, since it is
my impression that it is not commonly done.

Ross Pokorny

brettmc...@gmail.com

unread,
Jan 7, 2016, 10:16:04 AM1/7/16
to ozoneplatform-users
Thanks, Ross. I don't want to continuously barrage you with questions, but if you can help me with these last few, i'd surely appreciate it.

1. Writing a Java servlet seems to be the best route. I have a co-worker that can probably whip something up fairly quickly. Once he gets a jar file working, is there some sort of shell script in OWF that's responsible for starting up the .jar files?

2. General question: I browsed the OWF directory and found php files. What are those used for if there's no php capability?

3. If you can point me to an example of any of this that has been done already, I would greatly appreciate it. I'm working with an older version of OWF since we have to pull from Forge.mil, but perhaps there's something on there that's been done already?

Thanks so much!

Ross Pokorny

unread,
Jan 7, 2016, 10:42:34 AM1/7/16
to ozoneplat...@googlegroups.com
> 1. Writing a Java servlet seems to be the best route. I have a co-worker
> that can probably whip something up fairly quickly. Once he gets a jar file
> working, is there some sort of shell script in OWF that's responsible for
> starting up the .jar files?
You need to create a war file, not a jar file. A war is just a specialized
type of jar. Once you have a war file you put it in the webapps directory and
tomcat will deploy it automatically.


> 2. General question: I browsed the OWF directory and found php files. What
> are those used for if there's no php capability?
When I search for php files in owf, I only find them in example and demo
folders of third party JavaScript libraries that are included. Those php
files are not used by OWF and probably shouldn't really be included in the
bundle.

> 3. If you can point me to an example of any of this that has been done
> already, I would greatly appreciate it. I'm working with an older version
> of OWF since we have to pull from Forge.mil, but perhaps there's something
> on there that's been done already?
What you are talking about doing is just building a simple servlet
application. The fact that it will be co-hosted with OWF is incidental.
There are plenty of servlet tutorials and examples online.

Ross Pokorny

brettmc...@gmail.com

unread,
Jan 7, 2016, 10:44:34 AM1/7/16
to ozoneplatform-users
Thanks for your help!

brettmc...@gmail.com

unread,
Jan 8, 2016, 4:00:34 PM1/8/16
to ozoneplatform-users
Ross,

After reading through the other comments, I realized OWF does not support Java 8, until recently. Our government lab has updated to Java 8 and I'm in need of the most recent distribution of OWF. The problem is IA. They trusted the version 7.3 from Forge.mil, but that won't run on Java 8. Can you put me in touch with someone (with a .mil address) that can help me get the newest distribution that my IA guys will trust?

Thanks,

Brett

Michael Parizer

unread,
Jan 12, 2016, 7:50:02 AM1/12/16
to ozoneplatform-users, brettmc...@gmail.com
Brett,

We do not have the most current OWF sitting on a .mil address, however we do have it on DI2E which is government maintained. OWF 7.17.0 can be found at https://nexus.di2e.net/nexus/service/local/repositories/Private_OWFGOSS_Releases/content/org/owfgoss/owf/owf-bundle/7.17.0/owf-bundle-7.17.0.zip if you are unable to get to this we can try and put you in touch with someone that can get it to a mil address.

Mike Parizer
Reply all
Reply to author
Forward
0 new messages