0

i have a link to ajax.. it works.. now i want to add the current form values to ajax request..

$datepicker=$("#datepicker").val(); 

i know that i can use val() to get current values, but i am sending url here, where should i include this as datastring.. Hope am clear..This is my code

<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.1.min.js"></script>
<script>
$(document).ready(function(){
   $('a.member').click(function(e){ 
   e.preventDefault();
     $.ajax({
            type: "GET",
            url: this.href,
            cache:false,
            success: function(data){
                      $("#result2").append(data);
            }
     });
     return false;
}); 
});
</script>
<body>

<a href="http://ex.net/free/action.php?me=1"  class="member" id="member" rel="example">click to launch</a>

<br><br<
<form id="form1">

<input type="text" id="name" value="name"><br>
<input type="text" id="name1" value="name1">
</form>
<div id="result2"></div>

</body>
</html>

Thanks in advances,,

user2234992
  • 543
  • 4
  • 8
  • 20

3 Answers3

1

you should add the 'data' attribute in the ajax call:

$.ajax({
            type: "GET",
            data: "{'ParameterName': '" + $("#datepicker").val() + "'}",
            url: this.href,
            cache:false,
            success: function(data){
                      $("#result2").append(data);
            }
     });
1
<script>
$(document).ready(function(){
   $('a.member').click(function(e){ 
   e.preventDefault();
     $.ajax({
            type: "GET",
            data: {'postedData':$("#form_name").serialize()},  
            url: this.href,
            cache:false,
            success: function(data){
                      $("#result2").append(data);
            }
     });
     return false;
}); 
});
</script>
Arvind
  • 938
  • 9
  • 23
1
    $.ajax({
  type:"GET",
  url:this.href,
  data:"{'val': '" + $("#datepicker").val() + "'}",
  cache:false,
        success: function(data){
                  $("#result2").append(data);
        }
});

OR

Try this one.

       $.post(this.href,"val="+$("#datepicker").val());

Use data in ajax.hope this will work.

To get the value like $_REQUEST['val'].

For further process refer this link.

Community
  • 1
  • 1
Nirmal
  • 2,340
  • 21
  • 43