4 Replies - 604 Views - Last Post: 21 August 2011 - 11:14 AM

#1 E_Geek   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Running file through ajax.

Posted 21 August 2011 - 10:18 AM

Hey,

I'm using AJAX to process a .php page through JQeury. This .php file will create another .php file.

The next step is to run this created file in a divide on the original page, or show its output in this divide. Would I need to pass the filepath back using AJAX, then run the file in the outputting divide? If so, how would I do this in JQuery?

Or would I need to run the created .php file and then send its resulting output back through the ajax? and if so, how would I do that?

Or is their a better way for to do this?

Thank You Kindly :)

Is This A Good Question/Topic? 0
  • +

Replies To: Running file through ajax.

#2 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Running file through ajax.

Posted 21 August 2011 - 10:58 AM

Hey.

First off, why are you creating a new PHP file? Sounds like an unusual thing to do. Even a bit dangerous.


However, if you want the new PHP file shown on the page, it seems simplest to just execute a new AJAX request for it and put the returned output into your page. Could be as simple as this:
$.get('createPage.php', function(php_url) {
    $.get(php_url, function(php_output) {
        $("#output_elem").html(php_output);
    }
});


This assumes the createPage.php returns the name of the new PHP file as a text string.
Was This Post Helpful? 1
  • +
  • -

#3 E_Geek   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Re: Running file through ajax.

Posted 21 August 2011 - 11:03 AM

Hey, thanks :)

You know, it could well be dangerous.

I was looking at making a simple php code checker, was going to add the inputted code into a file and run the file to display the result, to show if it works or not.

Their would be functions I'd need to block for one, so I'm starting to think I may scrap this ... Any thoughts before I do scrap/continue it?
Was This Post Helpful? 0
  • +
  • -

#4 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4241
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: Running file through ajax.

Posted 21 August 2011 - 11:10 AM

Yea, that's definitely very dangerous. That would give people a LOT of access to your server; enough even to do some serious damage if they know what they're doing.

If you wanted to do this, you'd have to set up a very tight sandbox to execute things in. Perhaps just set up a virtual machine to execute the code in. That, at least, would isolate the host OS from this.
Was This Post Helpful? 1
  • +
  • -

#5 E_Geek   User is offline

  • D.I.C Head
  • member icon

Reputation: 46
  • View blog
  • Posts: 236
  • Joined: 20-February 11

Re: Running file through ajax.

Posted 21 August 2011 - 11:14 AM

Thanks :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1