Sue Hernandez's SharePoint Blog

SharePoint and Related Stuff

Passing Parameters to a Complete function – JQuery and AJAX

So I’m trying to create a dashboard with all kinds of great stuff.  You may have noticed my post on getting a Google Map using version 3 where you get the data from the Data Integration Toolkit (DIT).

What I was trying to accomplish now was a sort of INNER JOIN if you will, on data from 2 different locations.  So the way I chose to do it was, as I was iterating through the results of the first ajax call where I got the data from, I first created a Google Marker, and then I wanted to look up the related information based on the marker’s title, from another list again using AJAX.

The problem was, is that as soon as the Complete function was called for the second, related information list, I wanted to pass in the marker and send it into Fluster2Cluster for processing (

Unfortunately, the complete function only passes in 2 pieces of information into the function – the response data, and the status.  So I could not make a call such as the following:

	async: true,
	url: siteURL + "/_vti_bin/Lists.asmx",
	type: "POST",
	dataType: "xml",
	data: newSoapEnvelope,
	complete: ajaxCompleteFunction

which is how I normally had been making my ajax calls.  From what I could find, there was no way to “pass in” extra parameters.

So the resolution, however, was pretty simple.  Instead of putting the name of the function, you can actually define a function right there in the code.  Turns out that you can pass in variables right into the guts of that function.  Take the example below:

function getTicketCountFromList(marker, markup, last)
	var listGUID = "GUID_TO_LIST";
	var title = marker.getTitle();

	// Everything

		async: true,
		url: siteURL + "/_vti_bin/Lists.asmx",
		type: "POST",
		dataType: "xml",
		data: newSoapEnvelope,
		complete: function(xData, status) {
			// Geocode and set marker
			var xDoc = xData.responseXML;

			var nodes = xDoc.selectNodes("//z:row");
			var count = 0;

			if (nodes.length > 0) {
				count = nodes(0).getAttribute("ows_TicketCount");

			count = format_number(count, 0);

			fluster.addMarker(marker, markup, count);

			if (last)
		contentType: "text/xml; charset=\"utf-8\""

This way, I used the paramters “marker”, “markup” (for the InfoWindow), and “last” (specifying that it was the last marker to plot, so that we can initialize the Fluster2Cluster).


One response to “Passing Parameters to a Complete function – JQuery and AJAX

  1. yilmaz March 15, 2013 at 4:44 pm

    thank you!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: