Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8516111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:19:50+00:00 2026-06-11T05:19:50+00:00

Hello i got a question about jQuery ajax post request in ZendFramework here is

  • 0

Hello i got a question about jQuery ajax post request in ZendFramework here is my jquery:

$("input[type=image].addToCartButton").click(function() {
    var productId = $(this).attr("id");

    $.ajax({
        type: 'POST',
        dataType: 'html',
        url: "http://localhost/ZendProjects/essence/essenceZP/public/order",
        data: {
            id: productId
        },
        success: function(data){
            alert(data);
        }
    });

});

and here is my code in ZendFramework Order Controller:

    $request = $this->getRequest();
    if($request->isXmlHttpRequest()) {
        $this->_helper->layout()->disableLayout();
        $test = 'testing ajax content';
        $this->view->test = $test;
    } else {
        $test = 'testing non-ajax content';
        $this->view->test = $test;
    }

in firebug console i get an error but cant see where is the error because it shows for 0.5 sec and hide.. any ideas? The idea is when you click the button to send productId to the order controller and put it in session array, but for now only testing the ajax request..

markup:

    <form action="" method="post">
        <label for=".productQuantity" style="float: left;margin-top:7px;margin-left: 5px">Количество</label>
        <input class="productQuantity" name="productQuantity" type="number" value="1" min="1" max="1000" style="width: 50px;float: left;margin-left: 7px" />
        <input type="image" id="<?php echo $product->id; ?>" name="<?php echo $this->url(array('controller' => 'order', 'action' => 'add-to-cart'), 'default', true) ?>" src="<?php echo $this->baseUrl('images/cartPut.png'); ?>" style="margin-left: 13px;" />
    </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:19:52+00:00Added an answer on June 11, 2026 at 5:19 am

    What’s happening is that when you click on the submit button the ajax call is triggered at the same time the form is submitted.

    You may be wondering why the form is being submitted if there’s no action="".

    The thing is, when the action attribute is blank it assumes that it’s on the same page. I mean, if you’re on localhost/index.php than action="" = action="localhost/index.php"

    So, you must disable the form submit by adding action="javascript:void(0)".

    You can also use jQuery for this:

    cancel a submit in jquery?

    Or even plain javascript (return false to the submit event)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this code in my submit form <form id=myform action='hello.php' method='GET'> <input type=button
I've got a simple question about accessing variables in jQuery. Is there are way
Hello folks, I've got the issue to add a browser event to some input
Got a question about using mod_rewrite to redirect specific subdomains to use another domain.
Hello I searched for an answer to this question but didn't find any here.
Hello I was reading this question, I got confused with how if we can
I've got this model class Question < ActiveRecord::Base has_many :votes def to_s hello? end
Asking this question here because in CakePHP google group got no answer.I have the
To my previous question about segmentation fault ,I got very useful answers.Thanks for those
https://stackoverflow.com/a/64983/468251 - Hello, I have question about this code, how made that working with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.