I have this page which used to return some other JavaScript errors, but it seems I fixed them since the system now complains differently :)
Here is the page:
http://www.comehike.com/outdoors/parks/trailhead.php
And here is the JS error I am getting in the console:
Unable to post message to http://googleads.g.doubleclick.net. Recipient has origin http://www.comehike.com.
Also there is this error which is very cryptic:
Unsafe JavaScript attempt to access frame with URL http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-1884332214318974&output=html&h=90&slotname=6750679790&w=728&lmt=1307311140&flash=10.3.181&url=http%3A%2F%2Fwww.comehike.com%2Foutdoors%2Fparks%2Ftrailhead.php&dt=1307285940734&bpp=5&shv=r20110527&jsv=r20110506&correlator=1307285940857&frm=4&adk=540157337&ga_vid=898509444.1299013740&ga_sid=1307285941&ga_hid=824315563&ga_fc=1&u_tz=-420&u_his=10&u_java=1&u_h=768&u_w=1366&u_ah=720&u_aw=1366&u_cd=32&u_nplug=14&u_nmime=51&biw=1345&bih=149&ref=http%3A%2F%2Fwww.comehike.com%2F&fu=0&ifi=1&dtd=291&xpc=egJ5ygbjaM&p=http%3A//www.comehike.com from frame with URL http://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-1884332214318974&output=html&h=90&slotname=6750679790&w=728&lmt=1307311140&flash=10.3.181&url=http%3A%2F%2Fwww.comehike.com%2Foutdoors%2Fparks%2Ftrailhead.php&dt=1307285940734&bpp=5&shv=r20110527&jsv=r20110506&correlator=1307285940857&frm=4&adk=540157337&ga_vid=898509444.1299013740&ga_sid=1307285941&ga_hid=824315563&ga_fc=1&u_tz=-420&u_his=10&u_java=1&u_h=768&u_w=1366&u_ah=720&u_aw=1366&u_cd=32&u_nplug=14&u_nmime=51&biw=1345&bih=149&ref=http%3A%2F%2Fwww.comehike.com%2F&fu=0&ifi=1&dtd=291&xpc=egJ5ygbjaM&p=http%3A//www.comehike.com. Domains, protocols and ports must match.
Any idea why they are happening and how to resolve them?
Here is how I try to return the XML in the AJAX:
echo '<markers>';
$str =
<<<EOD
<marker>
trail_id=$trail_id
trailhead_id=$trailhead_id
park_id=$park_id
editor_member_id=$editor_member_id
trailhead_name=$trailhead_name
trailhead_description=$trailhead_description
parking=$parking
cost_details=$cost_details
parking_spots=$parking_spots
is_free=$is_free
wheelchair_accessible=$wheelchair_accessible
bathrooms_nearby=$bathrooms_nearby
lat=$lat
lng=$lng
</marker>
EOD;
echo $str;
// End XML file
echo '</markers>';
The error most likely is a side effect of something else going on on the page. Specifically something with the google maps API. The error Firefox throws is Error: uncaught exception: [Exception... "An invalid or illegal string was specified" code: "12" nsresult: "0x8053000c (NS_ERROR_DOM_SYNTAX_ERR)" location: "http://maps.gstatic.com/intl/en_us/mapfiles/api-3/5/5/main.js Line: 93"]. I would try and remove everything Google Maps related from the page and see if the page loads without errors. Also I would try and create another blank page and copy everything Google Maps related from this page the way it is there and see if just Google Maps code runs without errors. That would show me that: 1) either the code that works with the map is doing something funky, or 2) The google maps code is conflicting with something else on the page.
P.S. i suspect the culprit is initializeTrailheads() method. Try removing it from onload and see what happens.
Related
We have a basic form that we are trying to post to a MySQL database. Outside of AMP, it works.
When we submit the form with AMP, it returns the error: "Failed to parse response JSON:: Unexpected token".
Even when we remove the PHP from the handler script completely, it returns the same error.
We went right back to basics and just copied the example at https://ampbyexample.com/components/amp-form/ and changed only the line <form method="POST" action-xhr="/components/amp-form/submit-form" target="_top"> to point to action-xhr="https://ourdomain.com/form-handler.php".
So even with no PHP and this exact copy of the AMP by Example form, it returns the failed to parse response JSON error.
We have tried various bits of PHP to receive the JSON data but it doesn't just returns an error. We haven't been able to find any tutorials on how to write a compliant PHP handler script.
After many hours of Google, we've added these lines to our .htaccess:
Header set Access-Control-Allow-Origin "*"
Header set AMP-Access-Control-Allow-Source-Origin "https://ourdomain.com"
This has not helped unfortunately.
We haven't been able to find any other tutorials other than the AMP by Example page which only shows part of the process and not the handler script.
Thanks
I'm working on an application in PHP using Google YouTube API.
There seems to be a bug in the commentThreads.list resource.
Even the example code on Google developer site for PHP is broken.
( do they even run these scripts before posting ? :-\ this is the
4th script on their site under their examples that is broken not working code.
I have fixed all the other problems myself, but for some reason every time I try, or use an example script I get error 404 back.
Here is the section of code causing the problem.
// Call the YouTube Data API's commentThreads.list method to retrieve video comment threads.
$videoComments = $youtube->commentThreads->listCommentThreads('snippet', array(
'videoId' => $VIDEO_ID,
'textFormat' => 'plainText',
));
and here is the error it produces.
=================================================
A service error occurred: Error calling PUT https://www.googleapis.com/youtube/v3/commentThreads?part=snippet: (404) The specified comment thread could not be found. Check the value of the <code>id</code> property in the request body to ensure that it is correct.
=================================================
but the $VIDEO_ID is good, and works in the script prior to this block of code.
Why can't the comments list for the video be found ?
This fatal error stops the script.
any suggestions ? thanks in advance.
I'm working on a project which is simply scrapping the comments of youtube but the condition is not to use cURL. So i started using simple html dom.php.
I almost fought with many problems and now that are fixed. But i have a query that how to set an error for file_get_html() method.
For example:
I'm allowing user to enter the url of a youtube video, i have almost done a lot of validating of youtube URL, but still if someone will enter a wrong URL then the script will report this error:
*Warning: file_get_contents(http://www.youtube.com/watch?v=VR--anQO?????222cV--clS8): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\xampp\htdocs\utube\simple_html_dom.php on line 39*
and i can't set error reporting to false as it's not allowed. So can you please say me how to display this error: Invalid URL instead of the error shown above. And yes please don't say about the youtube API as it's not allowed :(
The easiest way would be to use an #. Just use it like this:
if (#file_get_html(...)) {
//do whatever you want, if it suceeds
} else {
echo "Invalid URL";
}
You can find more information here.
As simple_html_dom is a class, that should be the reason why the # has no affect, as the class don't seem to regard it.
A thing worth a try: First try using file_get_contents, and only use simle_html_dom, if that works - like this:
if (#file_get_contents(...)) {
file_get_html(...);
//now anything else you want to do
} else {
echo "Invalid URL";
}
I'm creating a global high score table. The JavaScript sends the username and score to the PHP through some AJAX functions and POST. The PHP script then takes the variable, and compares the score values to the file on the server. It then puts the new score where it should go on the score table, and rewrites the file.
I had it working last night, but now, when I call the function, it displays my code instead, and firebug gives the error, "No element found". I'm not sure what I did between then and now, but I just can't figure this one out.
This is my first time using PHP and AJAX, so I'm not sure where or what the error is.
Any help would be appreciated!
The exact error:
Timestamp: 4/13/2013 1:59:18 PM
Error: no element found
Source File: file:///C:/wamp/www/ajax.php
Line: 84, Column: 3
Source Code:
?>
If I cannot help you solve this issue, I will delete this answer, but I wanted to post it like this so you can better read my suggestions.
Start by changing your HandleResponse function to this:
function HandleResponse(response)
{
console.log(response);
document.getElementById('ResponseDiv').innerHTML = response;
}
and post the result that appears above the error, in firebug.
What we are doing here is adding a way for us to see if any data was actually returned from the AJAX request. A call to console.log tells the browser to print the given argument to the console (in your case, firebug).
UPDATE 1
In your comments, you stated that nothing displayed when you logged the value of response. This means that you received nothing back from the server (in terms of data, at least).
My next suggestion is that you change the call to MakeRequest to the following:
<input type='button' id="test" onclick='MakeRequest("*");' value='Global Highscore Table'/>
Like before, leave the console.log line in the HandleResponse method, and post the result that appears above the error in firebug.
Here, we are setting your MakeRequest to make a request that passes a wild-card query parameter. At the time of this suggestion, I did not realize that the requested file expected two arguments, nor that passing a wild-card would error the script. However, this was still a good thing to do, as we found a new error, which tells us that the request is being received.
UPDATE 2
Now, cut and paste everything from your "ajax.php" file to your notepad or another, similar application. Then, set the following to be the only content of the "ajax.php" file:
<?php echo "Request received and response sent"; ?>
Again, post the result of the console.log.
Here, we are taking a step back from fixing the complex code, and we are going back to the basics. All we want to do, here, is verify that we can both send the request and receive a response.
If "Request received and response sent" is successfully returned as the response of the request, then we know that the error lies in ajax.php, and not in the request. If it is not, we know that there is a problem with the request (be it a server issue or the request, itself). If the latter is the case, there could still be a problem with ajax.php, but we must first fix the request.
UPDATE 3 (final solution)
Issue was found to be due to not correctly running on the local server.
I am newbie in Prestashop module development so sorry if it is a fool question... I have been reading the docs but I haven't found what I am looking for so here I go,
I'd like to show a message on the screen (just for debugging purpose) with different context vars and so forth when actionCartSave. Something similar to "console.log()" or "alert()" in js.
Impossible to add the product to the cart.
textStatus: 'parsererror'
errorThrown: 'SyntaxError: JSON Parse error: Unrecognized token '<''
responseText:
< xmp style="text-align: left;" > message: < /xmp>
*{
"products": [...] *
I have already test this code:
public function hookActionCartSave( $params )
{
ppp('message: ');
return true;
}
...inside the module class definition but I am getting this error when I add a product to the cart:
I get this text in a different browser window.
So please, what is the best way to go?
Hope everything is clear. Thanks.
What you have done is correct, this error message is something thrown by javascript running in your browser since the additional information you are printing out using ppp isn't valid JSON.
If you use Chrome, use developer tools and select the Network tab. You will see the ajax call here. You can inspect this call in more detail by clicking on it.
Not sure it's the best option, but I found it useful to debug with a simple
throw new Exception('Custom message ' . $someVariable);