无法在'Document'jquery上执行'write'

时间:2016-12-19 01:53:32

标签: jquery

我在拉取数据和插入某些div时遇到了一些麻烦。我得到了Failed to execute 'write' on 'Document'。我使用jquery get来获取数据并将其循环到div#contentbox内,一些数据被拉出但有些数据生成失败'write' on 'Document'。我认为document.write()在文档就绪函数之后无法加载。

以下代码是使用get获取的示例数据:

<?php 
  $urlRedirect = urlencode('[VALUE_URL_REDIRECT_STACK_PAGE]&id=74');
?>
<div id="tiburon2">

<!-- START: Tiburon Inline Multi 2-->
<script type="text/javascript" src="http://someurl.com/generateplacementscript.aspx?placement=90989400&publisher=525182&affid=CD[VALUE_REV_TRACKER]&subid=&firstname=[VALUE_FIRST_NAME]&lastname=[VALUE_LAST_NAME]&email=[VALUE_EMAIL]&dob=[VALUE_DOBMONTH]/[VALUE_DOBDAY]/[VALUE_DOBYEAR]&zip=[VALUE_ZIP]&gender=[VALUE_GENDER_FULL]&ethnicity=&phone=[VALUE_PHONE1]-[VALUE_PHONE2]-[VALUE_PHONE3]&address=[VALUE_ADDRESS1]&redirect=<?php echo $urlRedirect ?>"></script>
<!-- END: Tiburon Inline --> 
<center><input name="button" id="button" value="Submit" class="submit_button_form" type="submit" onclick="javascript: return TMG_CheckForClick();" /></center>

</div>

使用数据提取进行更新:

 <?php if ($_SESSION['campaigns'] > 0) : ?>
  		// get campaigns data
  		var campaigns = [];
  			campaigns = <?php echo json_encode($campaign_link) ?>;
  		var campaignCount = campaigns.length - 1;
  		var url = '<?php echo $url; ?>'
  		var num = 0;
  		var barcount = '<?php echo $bar ?>';
  		var bar = barcount;
  		var progress = '<?php echo display_progress_bar($bar, $bar_num, true); ?>';
  		$('#progbar').append(progress);
  		$('.button-btn-submit').append('<button id="submit_stack_button" type="button" class="submit_button_form" align="absmiddle">Submit</button>');

  		var fetchCampaign = function(){
  		var link = 'http://pfrprefetch.dev/dynamic_live/survey_stack_curl.php?'+ url + 'get_stack_campaign_content_php?'+ campaigns[num];
  			$.get(link, function(data){
	  			var display = '';
	  			if (num  > 0) {
	  				var display = 'display: none;';
	  			}
	  			if (campaigns[num] == 'undefined') {
	  				alert('undefined campaign');
	  			}
  				if ($('li[data-id="'+ num +'"]').text() != '{"message":"Campaign does not exists."}') {
  					// console.log('num:' + num);
  					$('#contentbox ul').append('<li data-id="'+ num +'" style="list-style:none;'+ display +'">' + data + '</li>');
  					$('#contentbox ul').find('#submit_stack_button').remove();

  					if ($('#contentbox ul li').length == 0) {
  						alert('empty li');
  					}
  				}
  				num++;
	  		})
	  		.done(function(){
	  			if (num <= campaignCount) {
	  				$('#contentbox').waitMe("hide");
	  				fetchCampaign();
	  			}
	  		});
  		}
 
	  	fetchCampaign();

	  	var countClick = 0;
	  	var bar = barcount;
  		// Catch submit button
		$('#submit_stack_button').on('click', function(e){
			$('li[data-id="'+ countClick +'"] form').each(function () {
			      if($(this).find('.new-yesno-button input:radio:checked').first().length > 0) $(this).submit();
		 	});

			bar = +($('#progress_bar_current_number').text()) + 1;
			
			$("tr#progress_bar_row td:nth-child("+bar+")").toggleClass('cell_shade cell_noshade');
			$('#progress_bar_current_number').text(bar);

			$('li[data-id="'+ countClick +'"]').remove();
			countClick++;

			$('li[data-id="'+ countClick +'"]').show();
			// setTimeout(function(){
	  //    		if($("#contentbox ul li" ).size() == 0)
	  //    			window.location.href = 'http://someurl.com/no_loading/survey_stack.php?campaign='+ (countClick + 1);
		 //    }, 100);
			e.stopImmediatePropagation();
		});

  	<?php else: ?>
  		console.log('%c Campaings not ready! ', 'background: #222; color: #bada55');
	<?php endif; ?>

0 个答案:

没有答案