Ravi Mule
Ravi Mule

Reputation: 404

How to perform ajax call on anchor tag

<script>
$(document).ready(function(){
  $('#test').mouseover(function(){
          $('#test').ajaxForm({ 
            beforeSubmit: ShowRequest,
            success: SubmitSuccesful,
            error: AjaxError                               
          });                                    
       });    
       }); 
        function ShowRequest(formData, jqForm, options) {

        $("#loading").show();
        return true;
        }

        function AjaxError() {
        }

        function SubmitSuccesful(responseText, statusText) {  
  $(function() {
  var array=['ravi','abhi','raj','amol','neha','snehal','skksldfjsfsdfddsf','dkfks'];
    // add loading image to div
  $(function() {
    $("#test").attr('title',array.join('<br/>'));
    $("#test").tooltip({

        content:function(){return $(this).attr('title');},

   position: {
        my: "center bottom-20",
        at: "center top",
        using: function( position, feedback ) {
          $( this ).css( position );
          $( "<div>" )
            .addClass( "arrow" )
            .addClass( feedback.vertical )
            .addClass( feedback.horizontal )
            .appendTo( this );
        }
      }
   });  
});
});

 }    
  </script>

<div id="loading"></div>

<p>Ravi, Raj and <a href="#" id="test" title="enable to load">5 more</a></p>

it shows one error "Uncaught TypeError: Object [object Object] has no method ajaxForm.... Please tell me what changes should needed... on success of ajax call list should be my list should be display....... is there any way to solve this??

Upvotes: 0

Views: 745

Answers (2)

Kiran
Kiran

Reputation: 20313

.ajaxForm() is not a native jquery function. You have to include external js library to use .ajaxForm(). And important thing is .ajaxForm() will work with html form elements. I dont see form in your html code. If you want to use ajax call for your anchor just use .ajax() native function in your .mouseenter function:

Sample:

$.ajax({
  url: "test.html",
  context: content
}).done(function() {
  // add code here to execute after ajax call
});

Upvotes: 0

Ramesh Kotha
Ramesh Kotha

Reputation: 8322

Add this line to your head after jquery.js

<script src="http://malsup.github.com/jquery.form.js"></script> 

Reference

Upvotes: 1

Related Questions