0

I'm looking to dynamically add properties and values to my ajax parameters, does anybody know how to do this? I can't seem to figure out how to accomplish this task. Thanks

doLookup = function($field, url, query, process, filterIdArray) {

    $field.addClass("ajax-wait");

    return ajax(url, {
        parameters: {
            "t:input": query,
            "t:inputFilter": $filterField.val(),
            for (var i = 0; i < filterIdArray.length; i++) {
                "t:inputFilter_" + i : $("#" + myStringArray[i]);
            },
        },
        success: function(response) {
            $field.removeClass("ajax-wait");
            return process(response.json.matches);
        }
    });
};
1
  • @Arvind Bhardwaj I did last night, thank you Commented Sep 6, 2013 at 11:20

1 Answer 1

2

Create parameters outside the ajax function like:

params = {};
params["t:input"] = query;
params["t:inputFilter"] = $filterField.val();
for (var i = 0; i < filterIdArray.length; i++) {
    params["t:inputFilter_" + i] = $("#" + myStringArray[i]);
}
return ajax(url, {
        parameters: params,
        success: function(response) {
            $field.removeClass("ajax-wait");
            return process(response.json.matches);
        }
    });
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.