liderbug Posted March 7, 2020 Share Posted March 7, 2020 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. Link to comment Share on other sites More sharing options...
dsonesuk Posted March 7, 2020 Share Posted March 7, 2020 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now