0

I want to call a php script (with args) from HTML and to process the returned data I tried various flavours of :

<object id=test1 data="object.php" type="text/plain">

where object.php just returns a string, like

<?php print "firstText:Hello World";?>

I can't work out how to retrieve the returned string.
I was hoping to find it in something like

document.getElementById("test1").firstText
But no joy
Why am I doing this, you ask?
I'd like to get the page working interactively between the user and the server, avoiding the repainting of the browser window that comes with re-submitting with POST/GET.

3 Answers 3

1

Thanks for your responses. I'm not happy using JQuery - another layer beyond my control I have eventually found the returned text in

document.getElementById("test1").contentDocument.body.firstChild.textContent

which I can then work with. Thanks

Sign up to request clarification or add additional context in comments.

Comments

0

Use AJAX. Here's an example using jQuery:

$.get('yourpage.php', function(response){
    // response contains the string returned by your PHP page.
});

Comments

0

PaulPros idea is probably your best method. Don't forget to include jQuery.

Is there any reason you could not just make the .HTML a .php file and include your script?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.