I have 2 basic form used to convert data (type 1 <-> type 2).
I want to do my .post request using only 1 form.
I’m having issue with the [data] parameter for jquery.post
Here’s my code :
$('form').submit(function(){
var a = $(this).parent().find("input").attr('name');
var b = $(this).parent().find("input").val();
var url = $(this).attr('action')
$.post(url, { a:b },function(data) {
$(data).find('string').each(function(){
$('.result').html($(this).text());
});
});
return false;
});
The problem lies within {a:b}.
b is interpreted as my var b, but a isn’t, making my post parameters something like [a:1] instead of [param:1].
Is there a way to have a dynamic a?
Try this:
So like this: