Kissa Mia Kissa Mia - 15 days ago 7
jQuery Question

How to pass 2 values to AJAX function to be parsed as JSON?

I have an AJAX function

function updatelink(linktochange){


$.ajax({
type: 'POST',
url: "profile/...../rder.php",
data: {id:linktochange, value:val},
dataType: 'json',
cache: false,
success: function(result) {
alert ("Update successful!!")

}
});
}


and my jQuery

<input value="'+lnk+'" id="'+usId+'<seperator>'+orId+'<seperator>'+poId+'" class="linkinput" onBlur="updatelink(this.id)">\


I am able to send the ID using this.id, but how to send both ID and Value to the ajax to be parsed?

To be more specific I need something like this
onBlur="updatelink(this.id && this.value)
.

I don't even know what to search on the web to find an answer for the question.

Answer
 <input value="'+lnk+'" id="'+usId+'<seperator>'+orId+'<seperator>'+poId+'"  class="linkinput" onBlur="updatelink(this.id,this.value)">

    function updatelink(linktochange,val){


      $.ajax({
      type: 'POST',
      url: "profile/...../rder.php",
      data: {id:linktochange, value:val},
      dataType: 'json',
      cache: false,
      success: function(result) {
         alert ("Update successful!!")

      }
      });
    }
Comments