Pushpendra
Pushpendra

Reputation: 4392

Is it possible to call an action defined in indexController from jQuery.ajax?

I am trying to call an action defined inside the indexController using the Jquery.Ajax. But there is nothing happens. Since I am new to Zend and Ajax, I don't have any idea What was happening.

Is it possible to do so?

Thanks in advance.....

Upvotes: 1

Views: 154

Answers (1)

Richard Knop
Richard Knop

Reputation: 83755

Well, as far as I know, this has always worked for me:

$.ajax({
   type: "POST",
   url: "/module/controller/action",
   data: "id=5",
   success: function( response ){
     alert( 'ok:'+response );
   },
   error: function ( response ){
     alert( 'not ok:'+response )
   }
 });

Are you sure you can access the controller action via browser (try that to make sure it works)? It could be just a matter of mod_rewrite turned off in php.ini.

Could you post some code and explain what problem you're having?

Also try checking the Firefox error console (there are useful JavaScript errors and warnings sometimes).

Upvotes: 2

Related Questions