Jump to content
liderbug

document.body.appendChild return

Recommended Posts

document.body.appendChil
function extdb (a, b)
{
 var myval1 = a+","+b;
 e1 = document.createElement("script");
 e1.src = "sbsave.php?info="+myval1;
//alert (e1.src);
 e1.type = "text/javascript";
var ret = document.body.appendChild(e1);
alert (ret);
}

I have a web page, looks like a spreadsheet.  Some entries have a [ del ] or [ add ] onclick(extdb...) with them.
The sbsave.php script (in this case does a "curl" operation (another page does a mysql op).  So everthing
works fine - except for "RET". I can't get the JS/php to return the results of the operation .  When click on the
del/add on page the script executes the curl and I'd like it to popup an alert saying "Success" / "Failed" / "Already there"
from the output of sbsave.

Thanks.

 

 

Share this post


Link to post
Share on other sites

You trying to create javascript script tags then code after the page is rendered! through a function? All javascript must be applied on page load, call to functions, the elements they manipulate must exist at that time.

All ret refers to is the appending of child script tag and code to body, not any code returned.

You need to look into AJAX, it send request to server page, on return status success code (200) it return the results produced.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...