Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6103253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:42:28+00:00 2026-05-23T13:42:28+00:00

I’m using a cross-domain Ajax request to an external API. Every so often it

  • 0

I’m using a cross-domain Ajax request to an external API. Every so often it fails, with the console message:

Uncaught TypeError: Property 'photos' of object [object DOMWindow] is not a function

Looking at the JSON being returned, it is valid JSON, so it is not the fault of the external API.

I can’t reproduce the error reliably: the only factor that seems to trigger the error is when I call the request quickly and repeatedly.

In this case I’m calling the Ajax request when the user moves a Google map (to add markers to the map), and it occurs if the user moves around too quickly.

Here are the relevant parts of my code:

// Code located inside an external JS file referenced inside the head
// Not wrapped inside document.ready - but all the code setting up 
// the map (calling a function which calls a function which adds the 
// tilesloaded listener) *is* inside document.ready
function addMarkers() {
    var pm_url = "http://www.cyclestreets.net/api/photos.json?key=" + MY_KEY;
    $.ajax({
       url: pm_url,
       crossDomain: true, 
       contentType: "application/json",
       dataType: 'jsonp',
       data: pmdata,
       jsonpCallback: 'photos',
       success: function(data) {
        // TBA
       },
       error: function() {
           alert("Sorry, error retrieving photos!");
       }
   });
}
 google.maps.event.addListener(map, 'tilesloaded', function() {
 addMarkers(map);
 });

Having Googled a bit, the error Uncaught TypeError: Property 'photos' of object [object DOMWindow] is not a function generally seems to occur when jQuery has not been loaded.

However, I don’t see that this is relevant here, because the function is called from the map’s tilesloaded event – and it doesn’t generally fire the first time, it tends to fire after five or six rapid map resizes. So if it works once, the page surely can’t have ‘forgotten’ about jQuery?

Thanks for your advice.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:42:29+00:00Added an answer on May 23, 2026 at 1:42 pm

    If you want to specify the name of the function that jQuery creates from your success handler, but not actually define a separate function to use, you should use jsonp: 'photos' instead of jsonpCallback: photos. Currently it’s using photos in the URL which means it’s calling photos({ ...data... }) when the JSONP response comes back, and that doesn’t exist. Using the jsonp option on $.ajax() would create it. You have a few options here.

    You can do this (in a global scope) either of these two ways:

    function addMarkers() {
        var pm_url = "http://www.cyclestreets.net/api/photos.json?key=" + MY_KEY;
        $.ajax({
           url: pm_url,
           crossDomain: true, 
           contentType: "application/json",
           dataType: 'jsonp',
           data: pmdata,
           jsonpCallback: 'photos',
           error: function() {
               alert("Sorry, error retrieving photos!");
           }
       });
    }
    function photos(data) {
        // TBA
    }
    

    Or, what you intended I think:

    function addMarkers() {
        var pm_url = "http://www.cyclestreets.net/api/photos.json?key=" + MY_KEY;
        $.ajax({
           url: pm_url,
           crossDomain: true, 
           contentType: "application/json",
           dataType: 'jsonp',
           data: pmdata,
           jsonp: 'photos',
           success: function(data) {
            // TBA
           },
           error: function() {
               alert("Sorry, error retrieving photos!");
           }
       });
    }
    

    ….or just leave both off and let jQuery name the success callback itself (this happens by default, based on a timestamp).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.