Jump to content

Recommended Posts

http://paste.ee/p/OhiWv

 

The above is a link to a readable version of my code.  The XMLHTTPREQUEST worked, and the array was pulled down.  Was able to print out the undecoded/unparsed array.  However, immediately afterwards, all code stops working.

		<script>  
			var xhr;
			 if (window.XMLHttpRequest) { // Mozilla, Safari, ...
				xhr = new XMLHttpRequest();
			} else if (window.ActiveXObject) { // IE 8 and older
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			} 
				xhr.open("POST", "PHPLibrary/selectMemberResults.php", true); 
				xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
				xhr.send();
				xhr.onreadystatechange = display_data;
				var $phparray
				function display_data() {
				 if (xhr.readyState == 4) {
				  if (xhr.status == 200) {
				    //alert(xhr.responseText);	   
					$phparray = xhr.responseText;
					document.getElementById("suggestion").innerHTML = $phparray;
					//
					//
					//......................................................?
					// The above line of code is the last thing to print or 
					// to do anything that returns to the browser....
					//.......................................................?
					// All lines below do nothing............................?

					//
				  } else {
					//alert('There was a problem with the request.');
				  }
				 }
				}   
				document.write("Length of phparray Array :" + $phparray.length + "<");  
				var output = JSON.parse($phparray, function (key,val) {
					if ( typeof val === 'string' ) {
						// regular expression to remove extra white space
						if ( val.indexOf('\n') !== -1 ) {
							var re = /\s\s+/g;
							return val.replace(re, ' ');
						} else {
							return val;
						}
					}
					return val;
				} ); 
				document.write("Length of Array :" + $output.length + "<");
				for (var i=0; i < $output.length; i++)
					{
						document.getElementById("suggestion").innerHTML = $output[i].MEMBER_NAME;
					}  
		</script> 
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.