/    Sign up×
Community /Pin to ProfileBookmark

Need Help: Javascript loading issue

Hi Guys, I am facing a really odd issue here: my scripe will only work if I put a alert() at the end of the function.???
OK Here is the story:

As you can see the blowing code, it will only work if I put a line:” [COLOR=”Red”]alert(“thank”); [/COLOR]” otherwise, the function foodo (url) seems never been call, or say there is no text field been created.

Any idea why?

index page:

[code=html]
// I include a js file to index page:
<script type=”text/javascript” src=”https://xxx.com/my.js”></script>
[/code]

my.js

[code=html]
function foodo (url) {

// Create new JS element
var jsel = document.createElement(‘SCRIPT’);
jsel.type = ‘text/javascript’;
jsel.src = url;
document.body.appendChild (jsel);

return true;
}

function Caller(formID){

var elem = document.getElementById(formID).elements;
var str = ”;

for(var i = 0; i < elem.length; i++)
{
str += “&”+elem[i].name + “=”+elem[i].value;
}

foodo (‘http://xxx.com/createText.php?param=0’+ str);

alert(“thank”);
}

[/code]

createText.php page:

[code=php]

// Process passing values and creat a text file. This isn’t a big file.

[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@felgallDec 22.2008 — Is there actual JavaScript code in the createText.php file that can be run after that script finishes loading?

Does that code interact with the web page that has already finished loading before the script starts to run?

If the entire content of that page is inside a function or os expecting to interact while the page loads then it isn't going to work.
Copy linkTweet thisAlerts:
@Last_MinderauthorDec 22.2008 — Is there actual JavaScript code in the createText.php file that can be run after that script finishes loading?

Does that code interact with the web page that has already finished loading before the script starts to run?

If the entire content of that page is inside a function or os expecting to interact while the page loads then it isn't going to work.[/QUOTE]


  • 1. No JavaScript code in the createText.php


  • 2. the <script type="text/javascript" src="https://xxx.com/my.js"></script> is one time deal, it's been load once. and all the functions is use after the page is load


  • 3. Am not quite sure about you 3rd question, but this code will only if I put up alert("thank"); at the end of my.js page. I am just not sure why????
  • ×

    Success!

    Help @Last_Minder spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...