/    Sign up×
Community /Pin to ProfileBookmark

JavaScript with PHP

I have a file.txt with multiple lines. On each line some words. Now I made a JavaScript to run some PHP code. The PHP code fraps a random line of the file. Then I print the String in an empty text field. This works fine if I click the button to activate the code. But if I click it again it doesn’t make a new Random. It always takes the old one. But if I refresh the page and click the button again there is a new Random :/

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@rootSep 05.2017 — It helps if you post the code you are using.

Please use forum BBCode tags (see my signature for the different types) and wrap them around the code blocks you post.
Copy linkTweet thisAlerts:
@WebDevGermanyauthorSep 05.2017 — It helps if you post the code you are using.

Please use forum BBCode tags (see my signature for the different types) and wrap them around the code blocks you post.[/QUOTE]


Here are the important things of my code:

https://hastebin.com/zunapufiva.xml
Copy linkTweet thisAlerts:
@rootSep 05.2017 — Post the problem bits of code in this forum please.

Several reason for this that are not immediately obvious but are important, so here are a couple...

Pastebin and other code sites like that change, links go stale and the problem isn't immediately detectable, especially if the information has been updated.

It helps keep a record of what you had, where the problem is and how future changes resolved the problem, there is a record.

It is courteous to post the code here, expecting people to chase off around the internet isn't going to inspire many to help.

It also highlights if the code is JavaScript or not.

You can also do some checking yourself by reading the erros in the console log (F12 opens / closes the consoile)
Copy linkTweet thisAlerts:
@evoluerSep 08.2017 — Hey Webdevgermany,

I had a look at your code. It doesnt work this way. You need to use ajax or post to call the php file from javascript
×

Success!

Help @WebDevGermany 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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