The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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 |
#2
|
||||
|
||||
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.
|
#3
|
|||
|
|||
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> 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; } |
#4
|
|||
|
|||
Anyone can help with this? Dismounted?
|
#5
|
||||
|
||||
Did you check IE's error?
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|