Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/12/2017 in all areas

  1. You can't have multiple functions of the same name, Like in the film 'Highlander' there can be only one.
    1 point
  2. No! the PHP file in its present state should not be included in to the form page, it is AJAX specific because of the if condition, which should be access by JavaScript AJAX code that uses url to that php file to retrieve required data using server script language PHP. I don't know what jquery.js is? is it the users own custom code or jquery framework code? either way it is perfectly all right if not the norm to place js code at bottom of page, as it will help in loading of page quicker as html and css needs to loaded primarily first, and JavaScript secondary as most of the time JavaScript is triggered by events by the user after the page is fully loaded. The main problem with include ("jquery.js"); is that is needs to be within <script>...</script> tags if custom js code, OR if jQuery framework file, it should link to it, using for example <script type="text/javascript" src="jquery.js"></script>
    1 point
  3. OK. The advantage of using AJAX is to prevent having to reload the page each time the form is submitted, and the advantage of using PHP is to insure that the submitted data is sanitized and validated. Are implying with this that it is not possible to use Javascript for the purpose of sanitization and validation? If I have understood correctly, AJAX serves only as an intermediary between the form page and the PHP page. In other words, the PHP page should be written, as if the AJAX did not exist, and the AJAX should always refer to the PHP page via the following piece of code $.ajax({ url: 'ajax_comment.php', What is more, the PHP code should only be included in the page, if the following condition is satisfied. !isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) Thus, it was wrong for Loois to have included the following code at the bottom of his form page include ("jquery.js"); Under the assumption that all of the above is correct, why is the following code not entered at the top of the form page? include ("jquery.js"); My very best, Roddy
    1 point
  4. You should always provide a pure php script, to sanitize and validate, BECAUSE JavaScript CAN be disabled, You can use AJAX to update content, make database requests/update/insert etc without the need to reload the page constantly, which is required for pure php code to do the same thing. Usually you would not include the php script in the form page, only the AJAX JavaScript code would access it externally, to process the form data and return results to a specific location, it makes more sense this way checking with $_SERVER['HTTP_X_REQUESTED_WITH'] that it is a AJAX request. Without this it could be included in the form page, it would retrieve default information or content on loading of page, a AJAX request could be made using form using the same php script externally, the new AJAX returned results can be use to update/overwrite the default content without reloading the page.
    1 point
  5. So, why use AJAX at all? Since AJAX depends on Javascript being turned on or off, and since this decision is made by the user-client, why not use PHP whose functioning is determined solely by the host-server?
    1 point
  6. It would transfer the problem to AJAX code, it depends on WHY the ajax php code was included in the form page if (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); will not run php code beyond this 'if' condition, if page reloads because JavaScript was disabled which prevents the form being submitted, it is no longer a JavaScript AJAX request. if (!isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); Will allow the php code within the form to be processed if JavaScript disabled, BUT! will prevent AJAX request being processed if JavaScript is enabled and it goes directly to ajax_comment.php
    1 point
  7. OK. Thank you for the correction, Dsonesuk. I have never used AJAX and looked only for what was different from what I use -- namely, PHP. Upon a more careful reading I now see the statement include ("ajax_comment.php"); If I have further understood, you find the following statement to be ill-conceived, if (isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); and give as a reason that the PHP will only be used, if the Javascript succeeds. So, if Loois were to write, if (!isset( $_SERVER['HTTP_X_REQUESTED_WITH'] )):include('../config.php'); would this fix his problem.
    1 point
  8. Its AJAX, it does not require those, without action the form will submit to itself, and as that php file is included in the form page itself, which maybe used to takes into account if JavaScript is disabled it will then as said be submitted, page reloaded and processed by the same page, BUT! currently it will only show if AJAX request is sent ($_SERVER['HTTP_X_REQUESTED_WITH']), which seems pointless including in the form page as a non JavaScript alternative. While with JavaScript enabled, the form is prevented from being submitted, it gathers the input data and sends it to the php file specified in the JavaScript AJAX url code to be processed and return the result without reloading of page
    1 point
  9. There is no action attribute in the following line of code <form id="form" method="post"> You must enter an URL for ajax_comment.php as the value of your action attribute in the above <form> element. <form id="form" method="post" action='pathto/ajax_comment.php'> Replace the word "pathto" with whatever is necessary to connect the document that contains your form with the document that processes your $_POST variable -- namely, ajax_comment.php.
    1 point
  10. The PHP GD library can't open TIFF files, but it looks like ImageMagick can. If you don't have access to ImageMagick then you'll have to go through the tedious work of building a TIFF reader that parses binary TIFF files and extracts information from them.
    1 point
×
×
  • Create New...