We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19909
    • 49 Posts
    Hi,

    I have a live site at firstclassfinishltd.co.uk that is running on Revolution(PL). When I originally installed the site I was using the virtual host ie 77.235.XX.XX/~username which I have now altered in core/config.inc.php to the new site details and everything works - as such.

    However, I have two panels that utilize some external scripts that are housed in the assets/js the site can get hold of the initial javascript’s that run the form validation but for some reason beyond me - when these try to access the php files which fire off the emails (firebug returns a valid url for these files) the site reports in firebug that they are 404 documents not found ?

    I must add that the same code running on a local server works without question ?

    This is very frustrating and I’m hoping someone might be able to help shed some light on this ?

    Regards,

    mm
      • 19909
      • 49 Posts
      Just some extra info the script is using jQuery and Ajax to process the email:
             $.ajax({
            type: "POST",
            url: "assets/js/processcallback.php",
            data: dataString,
            success: function() {
              $('#formCallBack').html("<div id='returnMessage'></div>");
              $('#returnMessage').html("<h2 class='fcfH1Header'>Call Back Requested</h2>")
              .append("<p class='fcfPR'>Thank you, we will call you back shortly.</p>")
              .fadeIn(1500, function() {
                $('#returnMessage').append("");
              });
            }
           });
          return false;
          });


      This is the same url that works on the local site in MAMP - but safari & firefox (w/firebug) report that processcallback.php could not be found ?

      Wierd?
        • 19909
        • 49 Posts
        Wierd fix on this one. I had to move the php scripts out of the assets folder it wouldn’t execute them and also reupload them from the local site - although nothing had changed the files must have got corrupted or had different chown/chmod settings that were causing issues!!

        Can someone tell me whether you should be able to execute php files from within the assets folder or not ?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          That probably depends on your server’s configuration.

          I always use MODx resources for my AJAX processors; just use a resource with no template and no content except the snippet with the php code. No worries about loose-cannon .php files hanging around waiting to get hacked, no permission problems, and immediate full access to the MODx API and the database.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 19909
            • 49 Posts
            Thanks Susan,

            I had thought of trying that but was unsure about how to:

            a. Call the resource in the JS and
            b. The PHP script uses a require(’xxx.php’)

            Can the require be done in the same manner as a snippet and then called as one ?

            Regards,

            Mark
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              1. Just use mypage.html where you specify the URL for the AJAX request.

              2. sure. You can require other files from a snippet all you like. In fact, many snippets are really nothing more than some basic initialization then a require of the main code stored in a .php file.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 19909
                • 49 Posts
                I’ll have to try that tomorrow - its always nice to minimise the security issues on a site wink

                Off topic, but I dont suppose you would know why the formit validation isn’t working on the contact page would you?

                [[!FormIt? &hooks=`email,redirect`&emailTpl=`contactFormSend`&emailsubject=`Submission From Web Form`&emailTo=`clientsemailaddress`&redirectTo=`10`]]
                
                <p class="bodyCopy" style="color:#F00;">[[+fi.error.error_message]]</p>
                
                <form class="form iform" action="[[~[[*id]]]]" method="post">
                <ul>
                <li>
                <label for="YourName">*Your Name<span class="error">[[+fi.error.YourName]]</span>
                </label>
                <input id="YourName" class="itext" name="YourName:required" type="text" value="[[+fi.YourName]]" />
                </li>
                <li>
                <label for="YourEmail">*Your Email<span class="error">[[+fi.error.YourEmail]]</span>
                </label>
                <input id="YourEmail" class="itext" name="YourEmail:email:required" type="text" value="[[+fi.YourEmail]]" />
                  </li>
                <li><label for="Company">*Company<span class="error">[[+fi.error.Company]]</span>
                </label>
                <input id="Company" class="itext" name="Company:required" type="text" value="[[+fi.Company]]" />
                  </li>
                <li>
                <label for="YourMessage">*Your Message<span class="error">[[+fi.error.YourMessage]]</span></label>
                <textarea id="YourMessage" class="itextarea" name="YourMessage:required:stripTags">[[+fi.YourMessage]]</textarea>
                </li>
                <li>
                  <label for="Interestedin">Interested in</label><br />
                <ul>
                <li>
                <input id="lamination" class="icheckbox" name="lamination" type="checkbox" value="1" />
                <label class="ilabel" for="lamination">Lamination</label>
                </li>
                <li>
                <input id="uvfinish" class="icheckbox" name="uvfinish" type="checkbox" value="1" />
                <label class="ilabel" for="uvfinish">UV Finishes</label>
                </li>
                <li>
                <input id="special" class="icheckbox" name="special" type="checkbox" value="1" />
                <label class="ilabel" for="special">Specialised Finishes</label>
                </li>
                <li>
                <input id="diecut" class="icheckbox" name="diecut" type="checkbox" value="1" />
                <label class="ilabel" for="diecut">Die Cutting</label>
                </li>
                <li>
                <input id="foil" class="icheckbox" name="foil" type="checkbox" value="1" />
                <label class="ilabel" for="foil">Foil Blocking</label>
                </li>
                <li><input id="embossing" class="icheckbox" name="embossing" type="checkbox" value="1" />
                <label class="ilabel" for="embossing">Embossing</label>
                </li>
                </ul>
                </li>
                <li class="iseparator"> </li>
                <li><label> <input id="SendaMessage" class="ibutton" type="submit" value="Send a Message!" /></li>
                </ul>
                </form>​


                All the above is called as a chunk into the template...
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I know next to nothing about Revo or its add-ons. AJAX is pretty generic, though. Neither Revo nor Evo much care about the javascript stuff you do in the front-end.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org