问题
I'm experiencing this problem:
I want to add the Google Maps API to my Zend Framework application using the HeadScript Helper in the bootstrap:
$view->headScript()
->appendFile('/static/js/jquery-1.3.2.min.js')
->appendFile('/static/js/jquery-ui-1.7.1.min.js')
->appendFile("http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAfINi4Ug3nkoREt524GX3ABSFqzY8bf3muCS1IE0M5aBPGVvVxRRzm1PmTbIwi_tXaNcSoONdlIx_sA");
But for some reason everytime I try this I get an empty alert box as error. The weird part now is, that when I insert the same script with the same key using plain HTML, so a "wrong key" from Google is not the problem:
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAfINi4Ug3nkoREt524GX3ABSFqzY8bf3muCS1IE0M5aBPGVvVxRRzm1PmTbIwi_tXaNcSoONdlIx_sA" type="text/javascript"></script>
I do not get that empty alert box. Did you experience anything similar?
回答1:
I had this same issue - ZF encodes the script URI automatically, so & becomes &
Try
$view->headScript()
->appendFile('/static/js/jquery-1.3.2.min.js')
->appendFile('/static/js/jquery-ui-1.7.1.min.js')
->appendFile("http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAfINi4Ug3nkoREt524GX3ABSFqzY8bf3muCS1IE0M5aBPGVvVxRRzm1PmTbIwi_tXaNcSoONdlIx_sA");
回答2:
Weird I can only imagine it's a subtle difference in what's actually output - have you compared the output source of the two methods (using the headScript helper, and just hard coding the script tag) and seeing if there's any subtle difference?
来源:https://stackoverflow.com/questions/921811/zend-framework-wont-let-me-include-google-maps-api