Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

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.
0
KeithMcElroy
Asked:
KeithMcElroy
  • 5
  • 2
1 Solution
 
KeithMcElroyAuthor Commented:
0
 
KeithMcElroyAuthor Commented:
one possibility:  use serialize() to formulate the vales in to name&value pairs.
0
 
KeithMcElroyAuthor Commented:
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()
                              
                        });

                        
                  }
                  
      });
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RobOwner (Aidellio)Commented:
have you tried javascript objects?  then very easy to pass from one to the other

eg http://jsfiddle.net/ey7CR/

var myobject = {
    myarray: [4,5,2,6,7,8],
    name: "michael",
    subobject: {
        id: "sub"
    }
}

Open in new window

0
 
KeithMcElroyAuthor Commented:
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
0
 
KeithMcElroyAuthor Commented:
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.
0
 
RobOwner (Aidellio)Commented:
yes that would make sense.  i was referring to passing the values between the two javascript functions.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now