Results 1 to 6 of 6
  1. #1

    help question A jQuery question

    Hi all,
    I've added a form to my Zen shop and used jQuery to call a php script to validate the form when the submit button is pressed.
    I had to put this php script in a new folder at the root of my website. I tried it in my templates folder at first but it wouldn't work for some reason?

    The problem is, I can't use any of the standard Zen Cart functions from my script. Presumably because it is at the root or my website?

    Is there any way I can use the Zen Cart functions, such as zen_validate_email from my script?

    I've tried adding the following to the top of the script because I've seen other jQuery scripts do the same:
    Code:
    require('includes/configure.php');
    require_once('includes/application_top.php');
    But just those 2 requires cause the script to fail.

    I'm really grabbing at straws as you can see!
    I've been trying to write this for ages now but am getting nowhere.
    Can anyone spot what I'm doing wrong?

    Thank you!

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,761
    Plugin Contributions
    9

    Default Re: A jQuery question

    What is the name of the script?

    See the section in this tutorial about adding jScript
    https://www.zen-cart.com/tutorials/index.php?article=36
    Zen-Venom Get Bitten

  3. #3

    Default Re: A jQuery question

    I copied the method Ajax Banner Swapper uses and created a folder at my web site root called AJAX_servers and my script that is in there is called AJAX_ask_question_server.php

  4. #4

    Default Re: A jQuery question

    In case it helps, here's the jQuery code I use to call my script:
    Code:
    <script type="text/javascript">
    jQuery("askQuestion").eq(0).ready(function() {
    	jQuery(".submitform").submit(function(){		
    		jQuery.post("AJAX_servers/AJAX_ask_question_server.php", jQuery(".submitform").serialize(),
    		function(data){
    			if(data.email_check == 'invalid'){ 
    					jQuery("#error").html("<div class='errorMessage'>Sorry " + data.name + ", " + data.email + " is NOT a valid e-mail address. Try again.</div>"); 
    			} else {
    				jQuery("#error").html("<div class='successMessage'>" + data.email + " is a valid e-mail address. Thank you, " + data.name + ".</div>"); 
    				}
    		}, "json");
    		return false;
    	});
    });
    	
    </script>

  5. #5

    Default Re: A jQuery question

    I've read the jscript tutorial as you suggested Kobra but it doesn't really help with my problem.
    I have my javascript inserted in the right place and it's running correctly.
    What I would like to do is call one of the Zen Cart php functions from my php script that is located in htdocs/AJAX_servers

    For some reason I can't call any Zen Cart functions from my php script. I'm guessing it's because it's located outside of the includes folder.

    A better way to solve my problem would be to be able to call a php script that resides below the includes folder.
    Ive tried the following jQuery:

    jQuery.post("AJAX_ask_question_server.php"........
    This works if I have my AJAX_ask_question_server.php located in my root.

    If I try:
    jQuery.post("AJAX_servers/AJAX_ask_question_server.php".....
    This works too.

    If I try:
    jQuery.post("includes/AJAX_ask_question_server.php".....
    This fails even though I have uploaded my AJAX_ask_question_server.php script in to the includes folder.

    Do you know how I can call a php script that resides inside the includes folder?

  6. #6

    Default Re: A jQuery question

    Ok, I've found out why I can't access a php script from my jQuery javascript if it is insdide the includes folder....it's the .htaccess file that sits inside the includes folder.
    The .htaccess file is as follows:
    Code:
    # $Id: .htaccess 1105 2005-04-04 22:05:35Z birdbrain $
    #
    # This is used with Apache WebServers
    # The following blocks direct HTTP requests in this directory recursively
    #
    # For this to work, you must include the parameter 'Limit' to the AllowOverride configuration
    #
    # Example:
    #
    #<Directory "/usr/local/apache/htdocs">
    #  AllowOverride Limit
    #
    # 'All' with also work. (This configuration is in your apache/conf/httpd.conf file)
    #
    # This does not affect PHP include/require functions
    #
    # Example: http://server/catalog/includes/application_top.php will not work
    
    <Files *.php>
    Order Deny,Allow
    Deny from all
    </Files>
    So, as I'm useless on htaccess as well as jQuery, can anybody tell me a way I can stop this htaccess blocking jQuery requests for php scripts?

 

 

Similar Threads

  1. v139h Jquery
    By AmyS in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 23 Sep 2012, 09:21 PM
  2. JQuery Calculation
    By jazzman2 in forum General Questions
    Replies: 2
    Last Post: 9 Jan 2012, 01:52 AM
  3. Jquery?
    By cpdantha in forum All Other Contributions/Addons
    Replies: 3
    Last Post: 16 Feb 2011, 04:04 PM
  4. CSS Border Question and Jquery Rotator
    By ctrujillo in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 18 Jan 2011, 11:33 PM
  5. a jquery question
    By g_force in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 5 Sep 2009, 11:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR