I believe that for POST the correct way to send parameters is like
this:

data: {pageScroll: maxScroll, pageTime: endTime, location: currentURL}

However it is weird that it works for you in IE and Firefox, as you
have it now.
Worth a try anyway.


On Feb 11, 3:09 am, Karl Rudd <karl.r...@gmail.com> wrote:
> It's probably something to do with what Opera and WebKit allow in the
> unload handler. In fact doing a Google on "opera unload trigger link"
> turned up these two links:
>
>  http://objectmix.com/javascript/631919-unload-event-more-restrictive-...
>  https://bugs.webkit.org/show_bug.cgi?id=19922
>
> Karl Rudd
>
>
>
> On Wed, Feb 11, 2009 at 11:49 AM, Mike <malonem...@gmail.com> wrote:
>
> > Can anyone help me out with this? Here is a version of the update.php
> > script which will just write what the info it gets to a log file. I
> > found that the ajax works in IE and Firefox, but not on Chrome or
> > Opera:
>
> > update.php:
>
> > $debug = true;
>
> >  function update_log_event ($filename, $linenum, $message,
> > $extra_text="")
> >  {
> >     $log_filename   = dirname(__FILE__) . '/update_log.txt';
> >     $logfile_header = '<?php header("Location: /"); exit();' . "\r
> > \n" . '/* =============== Update LOG file =============== */' . "\r
> > \n";
> >     $logfile_tail   = "\r\n?>";
>
> >     // Delete too long logfiles.
> >     if (file_exists ($log_filename) && filesize($log_filename)
> >>1000000)
> >        unlink ($log_filename);
>
> >     $filename = basename ($filename);
>
> >     if (file_exists ($log_filename))
> >        {
> >        // 'r+' non destructive R/W mode.
> >        $fhandle = fopen ($log_filename, 'r+');
> >        if ($fhandle)
> >           fseek ($fhandle, -strlen($logfile_tail), SEEK_END);
> >        }
> >     else
> >        {
> >        $fhandle = fopen ($log_filename, 'w');
> >        if ($fhandle)
> >           fwrite ($fhandle, $logfile_header);
> >        }
> >     if ($fhandle)
> >        {
> >        fwrite ($fhandle, "\r\n// " . date("F j, Y, g:i a"). "|$filename
> > ($linenum)|: " . $message . ($extra_text?"\r\n//    Extra Data:
> > $extra_text":"") . $logfile_tail);
> >        fclose ($fhandle);
> >        }
> >  }
>
> >  if ($debug) {
> >    $message = "Update Started URL: " . $_POST['location'] . "
> > pageTime: " . $_POST['pageTime'] . " Scroll: " . $_POST
> > ['pageScroll'] . "\n";
> >    update_log_event (__FILE__, __LINE__, $message, $extra_text="");
> >  }
>
> > On Feb 10, 2:09 am, Mikedeezy33 <malonem...@gmail.com> wrote:
> >> I have a piece of code that updates a script with the page scroll and
> >> time on page when the user closes the page. I have this working in
> >> Firefox and IE, but it will not work in Chrome. Chrome will calculate
> >> the values correctly in jscript, but it will not post to the script. I have
> >> narrowed down the problem to being in the JQuery call to the ajax
> >> function. Does anyone know what I am doing wrong here?
>
> >> var maxScroll = 0;
> >> var pageOpen = new Date();
> >> var currentURL = window.location;
> >> var updateURL = "/wp-content/plugins/extra-tracking/update.php";
> >> var intervalUpdate = false;
>
> >>   if (intervalUpdate) {
> >>     setInterval( update, 15000);
> >>   }
>
> >>   jQuery(window).scroll(function(){
> >>       scrollPercent = Math.floor(jQuery(window).scrollTop() / ( jQuery
> >> (document).height() - jQuery(window).height() ) * 100 );
> >>       if (scrollPercent > maxScroll) {
> >>          maxScroll = scrollPercent;
> >>       }
> >>   });
>
> >>   function update() {
> >>     time = pageTime();
> >>     temp = jQuery.ajax({
> >>           type: "POST",
> >>           url: updateURL,
> >>           data: "pageScroll="+maxScroll+"&pageTime="+time
> >> +"&location="+currentURL
> >>           //success: function(msg){ alert("Page time: " + time + " Page
> >> Scroll " + maxScroll); }
> >>           });
> >>     return false;
> >>   }
>
> >>   function pageTime() {
> >>     curTime = new Date();
> >>     minutes = (curTime.getMinutes() - pageOpen.getMinutes());
> >>     seconds = (curTime.getSeconds() - pageOpen.getSeconds());
> >>     time = (seconds + (minutes * 60));
> >>     if (time < 0) { time = 0; }
> >>     return time;
> >>   }
>
> >> jQuery(window).unload( function ()
> >>   {
> >>      endTime = pageTime();
> >>      temp = jQuery.ajax({
> >>           type: "POST",
> >>           url: updateURL,
> >>           data: "pageScroll="+maxScroll+"&pageTime="+endTime
> >> +"&location="+currentURL
> >>           //success: function(msg){ alert("Page time: " + time + " Page
> >> Scroll " + maxScroll); }
> >>           //error: function (xhr, desc, exceptionobj) { alert
> >> (xhr.responseText); }
> >>           });
> >>   } );

Reply via email to