Jump to content


Popular Content

Showing content with the highest reputation since 04/24/2018 in Posts

  1. 1 point
    I'm not aware of a REMOTE_REFERER key in the $_SERVER array. Perhaps you meant to use HTTP_REFERER. But even then, an undefined key would not throw a 500 error. I can't tell you why it's doing that from just the code you provided, you should check the server's error log. If all you need is the referrer, though, Javascript already has that available without needing to send a request to the server. Use the document.referrer property.
  2. 1 point
    Did you even consider/think of just commenting out the last line to see what would happen? OR did you think it would cause launching of nuclear weapons from silos, ending life on this planet as we know it!
  3. 1 point
    AJAX is not the correct tool for this problem. Why do you insist on using it? I already gave a solution that does not require reloading the page, use Javascript. It does not need AJAX.
  4. 1 point
    That is returning values by index number $row4[0], $row4[1] etc, your code asks for associated array index by textual name 'TeamName', 'Coach' etc which would use mysqli_fetch_assoc($result4) in while loop.
  5. 1 point
    If you're working in a browser, the best approach is to add another <script> tag to your HTML document, everything declared globally in one Javascript file is accessible in all the other files that follow it. You seem to be working in Node.js. My experience with server-side Javascript is limited but there's a discussion about it here: https://stackoverflow.com/questions/4481058/load-and-execute-external-js-file-in-node-js-with-access-to-local-variables
  6. 1 point
    No. XHR requests are asynchronous, which means that the browser does not wait for them to finish before continuing. When you try to return that value, the request to the server hasn't even finished yet, it runs in the background. If you look at your code carefully, you'll notice that your loadPHPwithReturn function does not return a value, that function does not have a return statement. That's why it says undefined. The return statement you think is there is not inside that function, it's inside the onreadystatechange function. So you have the onreadystatechange function returning a value, but that value doesn't get returned anywhere. The internal stuff which handles the ajax request and calls the readystatechange function doesn't do anything with whatever that function returns. This is the nature of asynchronous things - they run in the background and finish at some point in the future. The purpose of the onreadystatechange callback is so that you can figure out when it has finished, and do whatever you want with the result.
  7. 1 point
    You need to learn two things: Linear interpolation Timing in Javascript Linear interpolation is described here with some examples of function implementations: https://en.wikipedia.org/wiki/Linear_interpolation#Programming_language_support The time t in linear interpolation is a value from 0 to 1. To get this value, you just divide the amount of time that has passed since the animation started by the total duration of the animation. In pseudo-code, something like this: t = (currentTime - startTime) / (endTime - startTime) When the animation starts, you need to store the current time in a variable startTime to use it in the formula described above. In Javascript, when using setTimeout or setInterval, you get the startTime and currentTime values from the Date object's getTime() method. If you're using requestAnimationFrame, see Mozilla's documentation, the current time is given as a parameter in the callback function. When using requestAnimationFrame you can get the startTime value using performance.now() right before the animation begins.
  8. 1 point
    Have you built this function or are you asking how to build it? In Javascript, you would have to implement it by repeatedly calling a function using setTimeout, setInterval or requestAnimationFrame.
  9. 1 point
    There's not a rule that says the hash value cannot contain or start with a question mark, as far as I'm aware. The question mark has no special meaning in that location. I don't know why they used it, maybe as a delimiter or maybe as a way to fool some faulty URL checker into considering that a valid URL (which it is). I'm not sure what that means. I don't even know if that part of the URL is even sent by the browser to the server. You could test that though, if you print the entire $_SERVER array you'll see what the browser sent to the server and what PHP did with it.
  10. 1 point
    The URL in example 3 is not valid. In the specification for URLs, the optional querystring precedes the optional fragment/anchor. Here's the actual RFC: https://www.ietf.org/rfc/rfc1738.txt No. It's supposed to, that was the original purpose. When people realized they could set that value without the page refreshing and use it for bookmarking or other clever ways inside their Javascript applications, they extended the usage of it.
  11. 1 point
    Nothing that follows the hash ever gets sent to the server, not even if it looks like a query string. The hash is always the last part of the URL. In item 1), the server loads the index page. In item 2) the server loads the index page with access to the contents of the query string. Item 3) is identical to item 1), no additional information is sent to the server because all of the remaining data is in the hash, which is only used by the browser. HTTP is very commonly used in web services, so it's not out of place to ask about it on the Web Services forum, but most of your usage of HTTP pertains to HTML and PHP, so either of those forums would work as well.
  12. 1 point
    It does not improve SEO, in fact it's detrimental. I don't know where you heard that. You actually have it backwards, all hashes belong to the same page, Google treats different query strings as different pages. What does improve SEO is using a hash instead of nothing at all when using AJAX to change the page content. AJAX in itself is bad for SEO but some search engines offer the ability to use the hash to indicate that the page has changed, which reduces the harm of a Javascript-driven website. For Google, the hash must have a specific format, something similar to #/!/page-name, I'd have to look it up again to make sure I got that right. In conclusion, don't use the hash to identify your pages.
  13. 1 point
    I can't help you if you don't show me the code in a context where it doesn't work.
  14. 1 point
    echo is used to show something to use user. The return keyword is used to send data from a function to the code that called the function.
  15. 1 point
    Your functions should be using return, not echo.
  16. 1 point
    I suppose it would be more correct to say that any metacharacter that is part of your data needs to be escaped. So if the data you are passing contains metacharacters like "#", "%", "&", "?", etc, as part of the data then those characters need to be escaped. They have special meanings when used in a URL, just like ":", "/", "@", etc.
  17. 1 point
    The rawurlencode() and encodeURIComponent() functions transform any non-ASCII values into ASCII, that's exactly what they are for. I said query string components, which refers to these sections: ?a=component1&b=component2 If you do not escape =, ? and & in those values then you will not get the values you expect in the server. The following example is a query string that will not give the desired value on the server: ?candy=M&Ms. If you do not escape the &, then the server will see a key "candy" with value "M" and another key "Ms" with no value.
  18. 1 point
    The input tag does not save the file on the server, it just transmits the file data across the internet. The actual saving of the file is being done by server-side code that you wrote. You write the software that saves files and keeps track of them. When you delete a record from the database, the record needs to provide information about the location of the file on the server. Before deleting the record, find this information and use it to delete the file.
  19. 1 point
    You're measuring things they are clicking inside the iframe, right? If you're trying to measure things they click on the parent site from inside the iframe, you're not going to be able to do that because Javascript running inside the iframe can't interfere with the parent site if it's on another domain. If you're just trying to measure how many times the iframe gets shown, that's as easy as updating a database table every time your page gets loaded. That kind of terminology is part of why people are confused. You're not talking about linking to your site, you're talking about embedding an iframe. Those are completely different things. Linking to your site means putting an anchor tag on the page pointing to your site. That's not what you're talking about here. And if you're talking about "impressions", using the same terminology that advertisers use, then you're just counting page views for the page that's inside the iframe. That's what I described above.
  20. 1 point
    There are several ways to do this as explained here https://stackoverflow.com/questions/369602/php-delete-an-element-from-an-array?rq=1 Since you know the value/s you might as well use array_diff() <?php $pic_array = [1, 2, 3, 4, 5, 6, 7, 8, 9]; echo '<p>remove key/value, but not reseting remaining keys using array_diff()</p>'; $remove = [6]; $pic_array = array_diff($pic_array, $remove); var_dump($pic_array); echo '<p>remove multi keys/values, but not reseting remaining keys using array_diff()</p>'; $remove = [6, 2]; $pic_array = array_diff($pic_array, $remove); var_dump($pic_array); echo '<p>reseting remaining key values using array_values()</p>'; $pic_array = array_values($pic_array); var_dump($pic_array); ?>
  21. 1 point
    Because the link on clicking, does want it normally does (even though it is empty, it is still linking to itself) so the update of hidden input then submission does get a chance to execute. You need to prevent the anchor doing what it normally does with event.prevent.Default() php echo "<a href=\"\" onclick=\"examine('Hello',event)\">examine</a>"; JS function examine(parametre, e) { e.preventDefault(); document.getElementById('myinput').value = parametre; document.getElementById('myform').submit(); }
  22. 1 point
    No, it shouldn't work, because date_diff returns a DateInterval object. You are doing this: if ($DateIntervalObject < 32) You're comparing a DateInterval object with a number, hence the error that the DateInterval object could not be converted to an integer. This is the DateInterval object: http://php.net/manual/en/class.dateinterval.php It has a days property that you can use to get the number of days, if the object was created using date_diff.
  23. 1 point
    Also, for what it's worth, URLs do have a maximum size limit, and it's not the same across browsers. So, be careful about how much you decide to cram into a querystring. If you can use a post request instead, do so.
  24. 1 point
    I think I just figured it out - I searched further and the example they give in the 'jQuery AJAX' methods section gives a better example than in the "tutorial". They use a variable there and I understand how to use it now. Be careful - I've got a variable and I know how to use it!! I hope this post will help someone else if they have the same question.
  25. 1 point
    I have a doubt from the 'W3Schools' JS Tutorials, It is given below. The 'var y=123e5' produces 12300000.And 'var z=123e-5' produces 0.00123I did'nt understand what 'e5' and 'e-5' are stands for and how formed 12300000 from '123e5'and 0.00123 from '123e-5' ? The code given below. <script type="text/javascript">{var y=123e5;var z=123e-5;document.write(y+"<br/>"+z);}</script>