KeithMcElroy
asked on
jquery ajax plug in dynamic options
How can I make the attached snippets dynamic.
I need all of the name value pairs created in Snippet 1 to pass thru to Snippet 2 without revising Snippet 2.
I would like snippet 1 to be based on an array, something like
arrList = New Array("url", "destination", etc)
for(x = 0; x < arrList.length;x++)
{
arrList[x] + ":" + $('#' + arrList[x]).val()
}
This would make the solution much more scalable.
I need all of the name value pairs created in Snippet 1 to pass thru to Snippet 2 without revising Snippet 2.
I would like snippet 1 to be based on an array, something like
arrList = New Array("url", "destination", etc)
for(x = 0; x < arrList.length;x++)
{
arrList[x] + ":" + $('#' + arrList[x]).val()
}
This would make the solution much more scalable.
ASKER
one possibility: use serialize() to formulate the vales in to name&value pairs.
ASKER
is there a way to pass the contents of the variable ser to the ajax functon as a get?
$(document).on('keypress', 'input', function(){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
var ser = $('form').serialize();
$().qbeexecSearch({
'url' : 'TSRIQBEF/jx/searchjx.asp' ,
'destination' : '#searchtarg',
'exectype' : 'search',
'pe_id' : $('#pe_id').val() ,
'pe_name' : $('#pe_name').val() ,
'pe_first' : $('#pe_first').val(),
'pe_last' : $('#pe_last').val(),
'pe_middle' : $('#pe_middle').val(),
'pe_url' : $('#pe_url').val()
});
}
});
$(document).on('keypress',
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode == '13'){
var ser = $('form').serialize();
$().qbeexecSearch({
'url' : 'TSRIQBEF/jx/searchjx.asp'
'destination' : '#searchtarg',
'exectype' : 'search',
'pe_id' : $('#pe_id').val() ,
'pe_name' : $('#pe_name').val() ,
'pe_first' : $('#pe_first').val(),
'pe_last' : $('#pe_last').val(),
'pe_middle' : $('#pe_middle').val(),
'pe_url' : $('#pe_url').val()
});
}
});
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So, sounds very good. How would I pass the object into the ajax data?
I guess the flow would be
1. create the object
2. pass the object into the ajax
I guess the flow would be
1. create the object
2. pass the object into the ajax
ASKER
the more I think about it, the more it makes sense to me to simply pass the serialized values so that they get picked up by the receiving ajax page which is an asp page
$('form').serialize();
Request(""formfield)
Hope makes sense.
$('form').serialize();
Request(""formfield)
Hope makes sense.
yes that would make sense. i was referring to passing the values between the two javascript functions.
ASKER
EEsample-09012012.odt