Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2009, 09:49 PM
RealAdvice RealAdvice is offline
 
Join Date: Dec 2008
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Can send private message via AJAX in FF not IE!?!

I am wanting to send private messages via AJAX but the script will not echo a response via AJAX in IE6 or IE7???? Below is code, what am I doing wrong?? A link opens a form in MoodalBox, then should post the result to private.php.

Code:
Removed
Reply With Quote
  #2  
Old 01-26-2009, 04:34 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've found that IE is extremely picky about Javascript. When you run the script in IE and IE doesn't like it, you should see a yellow warning sign in the bottom right corner. Click this to find the error.
Reply With Quote
  #3  
Old 01-28-2009, 02:47 PM
RealAdvice RealAdvice is offline
 
Join Date: Dec 2008
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the tip. Here's the result so far...

I have a separte .php page that works. It will look for when you click the submit button and send the result via Ajax. Works in FF3 and IE7.

Tried to integrate this into the member.php page. I want to have the user click a link or graphic and pass two variables to the form (hidden fields such as who the message is going to) and also add the security token as a hidden field on the form. This works successfully. However, when I try integrating the two together, I can't save the form results via Ajax. The security token is missing! What's weird as well is in my stand alone .php script, I don't need to pass a queryString to the YAHOO.util.Connect.asyncRequest in the fourth variable, but it seems I do when I integrate within a js function.

Here's what I have from a bird's eye view:

Example 1:
sample_yui_ajax.php
1. First shows the HTML form on the page with static values placed in the appropriate values of the form to test sending (security token, my user id and username, username of who i want to send the test message to via ajax).
2. JS declares an object AjaxObject for all the ajax functionality.
3. After the AjaxObject declaration, calls YAHOO.util.Event.addListener(window, 'load', AjaxObject.init); which will wait for the user to click the submit button and send the result.

Example 2:
member.php
1. Link on the page next to a user name will call a js function and pass 2 variables.
2. Via ajax, passes 2 variables and retrieves the username, current security token, etc to put values into the private message form.
3. Creates the form and echoes the html for the form.
4. The function adds the form to a div.
5. When the listener looks for the user to submit the form, I get a message that the security token is missing.

I've narrowed it down to the listener. Any suggestions?

Code below:
Example 1:
Code:
<body>  
<?php

	$results = <<<FORM
<div id="myajaxprivatemsg_container">
<form name="myajaxprivatemsg_form" id="myajaxprivatemsg_form">

<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">
<tr>
	<td class="tcat">Send New Private Message</td>

</tr>

<tr>
	<td class="panelsurround" align="center">
	<div id="myajaxtest_dialog_text" class="panel">
		<div align="left" style="max-width:640px; width:auto !important; width:480px">
		
		<!-- recipients field -->
			<table cellpadding="0" cellspacing="3" border="0">
			<tr>
				<td class="smallfont">
					
					<div id="pmrecips">
					    <table width="100%">
						  <tr>
						    <td width="75" valign="top" class="smallfont">
							  $touseridpic
							</td>
							<td width="75" valign="top" class="smallfont">
							  <br/>
							  To:<br/><br/>
							  Subject:
							</td>
							<td valign="top" class="smallfont">
							  <br/>
							  <b>$recipients</b><br /><br/>
							  <input type="text" name="title" id="title" value="$title" size="40" class="smallfont" />
							</td>
						  </tr>
						</table>
					</div>
			</tr>
			</table>
		<!-- / recipients field -->

		<!-- message area -->
			<table cellpadding="0" cellspacing="3" border="0">
			<tr>
				<td class="smallfont">
					
					<!--script type="text/javascript" src="/clientscript/vbulletin_ajax_namesugg.js?v=380"></script-->
					
					<div>Message:</div>
					<div id="pmrecips">
						<textarea name="message" id="message" rows="4" cols="80" style="display:block; width:500px; height:95px" tabindex="1" class="smallfont"></textarea>
						<input type="hidden" name="s" value="" />
						<input type="hidden" name="recipients" id="recipients" value="$recipients" />
						<input type="hidden" name="userid" id="userid" value="$userid" />
						<input type="hidden" name="username" id="username" value="$username" />
						<input type="hidden" name="securitytoken" id="securitytoken" value="$securitytoken" />
						<input type="hidden" name="do" id="do" value="insertpm" />
						<input type="hidden" name="ajax" id="ajax" value="true" />
						<input type="hidden" name="wysiwyg" id="wysiwyg" value="0" />
						<input type="hidden" name="iconid" id="iconid" value="0" />
						<input type="hidden" name="pmid" id="pmid" value="" />
						<input type="hidden" name="forward" id="forward" value="" />
						</div>
			</tr>
			</table>

		<!-- / message area -->

					<div style="padding:3px" class="smallfont">
						<div><label for="cb_receipt"><input type="checkbox" name="receipt" value="1" id="cb_receipt" />Request a read receipt for this message</label></div>

						<div><label for="cb_savecopy"><input type="checkbox" name="savecopy" value="1" id="cb_savecopy" tabindex="1"  checked="checked" />Save a copy of this message in your <a href="private.php?folderid=-1">Sent Items</a> folder.</label></div>

					</div>		
		
		</div>
	</div>

	<div id="myajaxtest_buttons" style="margin-top:6px">
		<!--input type="submit" id="send_form" class="AjaxButtonBlue" value="Send"-->
		<input type="button" name="submitter" id="submitter" class="AjaxButtonBlue" value="Submit Message" accesskey="s" />
		<input type="button" name="cancel" id="cancel" class="AjaxButton" value="Cancel" tabindex="2" onclick="MOOdalBox.close();" />
	</div>
	</td>
</tr>
</table>

</form>
</div>
FORM;

	echo $results;

?>
 <!-- Scripts -->  
 
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/yahoo/yahoo-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/dom/dom-min.js"></script> 
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/event/event-min.js"></script> 
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/connection/connection-min.js"></script>
<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/animation/animation-min.js"></script>

<script type="text/javascript">

function pause(millis) 
{
  var date = new Date();
  var curDate = null;

  do { curDate = new Date(); } 
  while(curDate-date < millis)
}
	
var AjaxObject = {
   init: function() {
      // Grab the elements from the form
      AjaxObject.form = document.getElementById('myajaxprivatemsg_form');
      AjaxObject.ajaxSearchResult = document.getElementById('myajaxtest_dialog_text');
	  AjaxObject.ajaxSearchButtons = document.getElementById('myajaxtest_buttons');
	  AjaxObject.ajaxWholedoc = document.getElementById('myajaxprivatemsg_container');
      
      // Set the Ajax Search result div to 1 (aka visible) so we can see the progress meter
      YAHOO.util.Dom.setStyle(AjaxObject.ajaxSearchResult, 'opacity', 1);
      
      // Hijack the form
	  YAHOO.util.Event.addListener("submitter", "click", AjaxObject.myajaxsubmit_ajax_form);
   },
   
   myajaxsubmit_ajax_form: function(e) {
      YAHOO.util.Event.preventDefault(e);
      YAHOO.util.Connect.setForm(AjaxObject.form);
      
      // Temporarily disable the form while Ajax saves the data
      for(var i=0; i<AjaxObject.form.elements.length; i++) {
	    AjaxObject.form.elements[i].disabled = true;
      }

	  YAHOO.util.Dom.setStyle(AjaxObject.ajaxSearchResult, 'display', 'block');
	  
	  AjaxObject.ajaxSearchResult.innerHTML = "";
	  AjaxObject.ajaxSearchResult.innerHTML =
      '        <br /><br /><br /><br /><br /><br /><br /><br />' +
	  '        <span class=\"search_result_text\"><img src=\"/images/ajax/ajax_loading_blue_small.gif\"> Sending...</span>' +
      '        <br /><br /><br /><br /><br /><br /><br /><br />';
      AjaxObject.ajaxSearchButtons.innerHTML = "";

      var cObj = YAHOO.util.Connect.asyncRequest('POST', 'private.php', AjaxObject.myajaxtest_callback);
   },
   
   myajaxtest_callback: {
      success: function(o) {
	  var myajaxtest_respsonse_text = o.responseText;
		
	  // Set up the animation on the results div.
	  var myajaxtest_results_fade_out = new YAHOO.util.Anim(AjaxObject.ajaxSearchResult, {
		opacity: { to: 0 }
		}, 0.25, YAHOO.util.Easing.easeOut); // 0.25 is the time it takes to fade out
			
	  var myajaxtest_dialog_fade_out = new YAHOO.util.Anim(AjaxObject.ajaxWholedoc, {
		opacity: { to: 0 }
		}, 1.00, YAHOO.util.Easing.easeOut); // 0.25 is the time it takes to fade out

	  YAHOO.util.Dom.setStyle(AjaxObject.ajaxSearchResult, 'display', 'block');
	  
	  var myajaxtest_results_fade_in = new YAHOO.util.Anim(AjaxObject.ajaxSearchResult, {
		opacity: { to: 1 }
		}, 0.25, YAHOO.util.Easing.easeIn); // 0.25 is the time it takes to fade in
			
	  myajaxtest_results_fade_out.onComplete.subscribe(function() {
		AjaxObject.ajaxSearchButtons.innerHTML = "";
		AjaxObject.ajaxSearchResult.innerHTML = myajaxtest_respsonse_text;
		myajaxtest_results_fade_in.animate();
		//pause(5000);
  	    //myajaxtest_dialog_fade_out.animate();
	  });

	  myajaxtest_results_fade_out.onComplete.subscribe(function() {
		//Re -enable the form.
		for(var i=0; i<AjaxObject.form.elements.length; i++) {
		  AjaxObject.form.elements[i].disabled = false;
	  }});
		
	  myajaxtest_results_fade_out.animate();
      },
      
      failure: function(o) { // In this example, we shouldn't ever go down this path.
	    alert('An error has occurred');
      },
	  cache: false
   }

};

YAHOO.util.Event.addListener(window, 'load', AjaxObject.init);

</script>
	
</body>
Example 2:
Need to integrate into the below:

Code:
function myajaxtestPrivateMsgAJAX(catid,touserid) {
  var ajaxSearchResult = document.getElementById('myajax_privatemsg_ajaxresult');
  var queryString = "?ajax=true&catid=" + catid + "&touserid=" + touserid;
}
Reply With Quote
  #4  
Old 02-02-2009, 02:47 AM
RealAdvice RealAdvice is offline
 
Join Date: Dec 2008
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone can help with this? Dismounted?
Reply With Quote
  #5  
Old 02-03-2009, 05:30 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you check IE's error?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:19 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05410 seconds
  • Memory Usage 2,215KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete