[jQuery] Re: parseerror on GET from window.location

2009-06-19 Thread Nick Fitzsimons
2009/6/18 jacktanner i...@hotmail.com:

 I'm trying to do an AJAX GET.

            var q_url = window.location.toString();
            $.ajax({
                type: 'GET',
                        url: q_url,
                        cache: false,
                        dataType: 'json',
                        success: function(response, textStatus) { ... },
                        error: function (xhr, textStatus, errorThrown) {
                          alert(textStatus);
                        }
            });

 This triggers the error callback with textStatus == parseerror.

You're specifying a dataType of json, yet you're GETting the
original HTML page in which this code is running (window.location). As
HTML is not JSON, you should _expect_ a parse error.

Regards,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/


[jQuery] Re: parseerror on GET from window.location

2009-06-19 Thread James

That's a nice catch!

On Jun 19, 12:10 am, Nick Fitzsimons n...@nickfitz.co.uk wrote:
 2009/6/18 jacktanner i...@hotmail.com:





  I'm trying to do an AJAX GET.

             var q_url = window.location.toString();
             $.ajax({
                 type: 'GET',
                         url: q_url,
                         cache: false,
                         dataType: 'json',
                         success: function(response, textStatus) { ... },
                         error: function (xhr, textStatus, errorThrown) {
                           alert(textStatus);
                         }
             });

  This triggers the error callback with textStatus == parseerror.

 You're specifying a dataType of json, yet you're GETting the
 original HTML page in which this code is running (window.location). As
 HTML is not JSON, you should _expect_ a parse error.

 Regards,

 Nick.
 --
 Nick Fitzsimonshttp://www.nickfitz.co.uk/


[jQuery] Re: parseerror on GET from window.location

2009-06-18 Thread James

When you hardcode q_url, do you also put in the absolute path? (e.g.
http://www.balh.com/myscript.php) or only the relative path? (e.g.
myscript.php)

The _=1234567889 part is a result of using 'cache:false'. This gives
the URL a unique value every time so that a server request is always
done.

On Jun 17, 6:20 pm, jacktanner i...@hotmail.com wrote:
 I'm trying to do an AJAX GET.

             var q_url = window.location.toString();
             $.ajax({
                 type: 'GET',
                         url: q_url,
                         cache: false,
                         dataType: 'json',
                         success: function(response, textStatus) { ... },
                         error: function (xhr, textStatus, errorThrown) {
                           alert(textStatus);
                         }
             });

 This triggers the error callback with textStatus == parseerror. If I
 hardcode q_url, everything works. Stepping through with Firebug shows
 that q_url has the same value no matter if it's hardcoded or set via
 window.location.toString() (or window.location.href or
 window.location.pathname, which are all supposed to be strings
 according tohttps://developer.mozilla.org/En/DOM/Window.location).
 The browser is Firefox 3.0.11. Any ideas?

 A separate issue is that no matter whether the GET succeeds or fails,
 instead of going to q_url, it goes to a url like q_url + '?
 _=1245297612818'  (according to Firebug 1.3). What gives?


[jQuery] Re: parseerror on GET from window.location

2009-06-18 Thread jacktanner

When I hardcode q_url, I use a relative path. I tried
window.location.href (absolute path) and window.location.pathname
(relative path), and both of those give a parseerror. By the way, this
is jquery 1.3.2.

Thank you for explaning cache:false!

On Jun 18, 2:04 pm, James james.gp@gmail.com wrote:
 When you hardcode q_url, do you also put in the absolute path? 
 (e.g.http://www.balh.com/myscript.php) or only the relative path? (e.g.
 myscript.php)

 The _=1234567889 part is a result of using 'cache:false'. This gives
 the URL a unique value every time so that a server request is always
 done.

 On Jun 17, 6:20 pm, jacktanner i...@hotmail.com wrote:

  I'm trying to do an AJAX GET.

              var q_url = window.location.toString();
              $.ajax({
                  type: 'GET',
                          url: q_url,
                          cache: false,
                          dataType: 'json',
                          success: function(response, textStatus) { ... },
                          error: function (xhr, textStatus, errorThrown) {
                            alert(textStatus);
                          }
              });

  This triggers the error callback with textStatus == parseerror. If I
  hardcode q_url, everything works. Stepping through with Firebug shows
  that q_url has the same value no matter if it's hardcoded or set via
  window.location.toString() (or window.location.href or
  window.location.pathname, which are all supposed to be strings
  according tohttps://developer.mozilla.org/En/DOM/Window.location).
  The browser is Firefox 3.0.11. Any ideas?

  A separate issue is that no matter whether the GET succeeds or fails,
  instead of going to q_url, it goes to a url like q_url + '?
  _=1245297612818'  (according to Firebug 1.3). What gives?


[jQuery] Re: parseerror on GET from window.location

2009-06-18 Thread pinku

hi,

try to use escape function for your url.

thanks
prashant

On Jun 18, 12:27 pm, jacktanner i...@hotmail.com wrote:
 When I hardcode q_url, I use a relative path. I tried
 window.location.href (absolute path) and window.location.pathname
 (relative path), and both of those give a parseerror. By the way, this
 is jquery 1.3.2.

 Thank you for explaning cache:false!

 On Jun 18, 2:04 pm, James james.gp@gmail.com wrote:



  When you hardcode q_url, do you also put in the absolute path? 
  (e.g.http://www.balh.com/myscript.php) or only the relative path? (e.g.
  myscript.php)

  The _=1234567889 part is a result of using 'cache:false'. This gives
  the URL a unique value every time so that a server request is always
  done.

  On Jun 17, 6:20 pm, jacktanner i...@hotmail.com wrote:

   I'm trying to do an AJAX GET.

               var q_url = window.location.toString();
               $.ajax({
                   type: 'GET',
                           url: q_url,
                           cache: false,
                           dataType: 'json',
                           success: function(response, textStatus) { ... },
                           error: function (xhr, textStatus, errorThrown) {
                             alert(textStatus);
                           }
               });

   This triggers the error callback with textStatus == parseerror. If I
   hardcode q_url, everything works. Stepping through with Firebug shows
   that q_url has the same value no matter if it's hardcoded or set via
   window.location.toString() (or window.location.href or
   window.location.pathname, which are all supposed to be strings
   according tohttps://developer.mozilla.org/En/DOM/Window.location).
   The browser is Firefox 3.0.11. Any ideas?

   A separate issue is that no matter whether the GET succeeds or fails,
   instead of going to q_url, it goes to a url like q_url + '?
   _=1245297612818'  (according to Firebug 1.3). What gives?- Hide quoted 
   text -

 - Show quoted text -