मैं क्रोम एक्सटेंशन में चैनल एपीआई का उपयोग कर रहा हूं।Google ऐप इंजन चैनल API (jsapi) क्रोम एक्सटेंशन में लोड करने में विफल क्यों होता है?
Google App Engine Channel API Javascript Reference (Python) पेज में यह कहा गया है कि
Include the following in your html page before any JavaScript code that refers to it:
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
तो, मैं डाल दिया है कि मेरे options.html फ़ाइल के शीर्षक में:
<html>
<head>
<title>Extension Options</title>
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
</head>
लेकिन क्रोम jsapiFailed to load resource
त्रुटि फेंकता है। मैं क्या गलत कर रहा हूं?
अद्यतन
Moishe के जवाब के अनुसार, मैं इस तरह JSAPI करने के लिए कॉल अद्यतन:
<head>
<title>Extension Options</title>
<!-- this does not work because it is local
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
-->
<script type="text/javascript" src="https://talkgadget.google.com/talkgadget/channel.js"></script>
</head>
अद्यतन
मैं onopen
और अन्य गुण गयी। अब मुझे onopen
अलर्ट मिल गया है लेकिन मुझे evt.data
अलर्ट नहीं मिल रहा है। मैं क्या गलत कर रहा हूं?
<html>
<head>
<title>Extension Options</title>
<!-- this does not work because it is local url
<script type="text/javascript" src="/_ah/channel/jsapi"></script>
-->
<script type="text/javascript" src="https://talkgadget.google.com/talkgadget/channel.js"></script>
</head>
<body>
<p>Enter your gmail address:</p>
<textarea id="getEmail" style="margin-bottom: 4px; width: 250px; height: 20px">
</textarea><br />
<button id="save">Save</button>
<!--<button id="save">Clear</button>-->
<script>
document.getElementById("getEmail").placeholder = "your gmail address" ;
//save entered gmail address
document.getElementById("save").addEventListener
(
"click",
function()
{
var userEmail = document.getElementById("getEmail").value;
var formData = new FormData();
formData.append("extension_user", userEmail);
alert("after formData.append")
var channel;
var socket;
var handler =
{
onopen: function() { alert("onopen") },
onerror: function() { alert("onerror") },
onclose: function() { alert("onclose") },
onmessage:
function (evt)
{
//evt.data will be what the server sends in channel.send_message
console.log("evt.data received from authhandler: " + evt.data);
alert("evt.data is: " + evt.data)
}
};
var xhr = new XMLHttpRequest();
//changed to lowercase
xhr.onreadystatechange = function()
{
//alert("xhr.onReadyStateChange")
//error handling etc not included
if (xhr.readyState == 4 && xhr.status == 200)
{
token = xhr.responseText;
alert("token: " + token)
channel = new goog.appengine.Channel(token);
socket = channel.open(handler);
}
};
xhr.open("POST", "http://ting-1.appspot.com/authsender", true);
xhr.send(formData);
console.log("formData sent to authsender: " + formData);
}, false
)
</script>
</body>
</html>
क्या यह dev_appserver या उत्पादन में उपयोग कर रहा है? क्या आप क्रोम देव उपकरण में "नेटवर्क" टैब के लिए कोई विवरण प्रदान कर सकते हैं? –
यह उत्पादन में है। सबसे पहले "नेटवर्क" टैब में कुछ भी नहीं था; तो मैंने निर्देश के अनुसार पेज को पुनः लोड किया और मुझे 2 आइटम दिखाई दिए: options.html और jsapi: name: options.html; विधि: प्राप्त करें; स्थिति: (कैश से); प्रकार: text/html; आकार: (कैश से); समय: 3 एमएमएस और 'जेएसपीआई/_ए/चैनल; प्राप्त करें, (असफल); अपरिभाषित; 30B; 5 एमएमएस धन्यवाद! – Zeynel
क्या आप मुझे अपना एपिड बताते हैं? यदि आप सीधे "http://your-app-id.appspot.com/_ah/channel/jsapi" पर नेविगेट करने का प्रयास करते हैं तो क्या होता है? –