有人必须能够解释我在这里做错了什么!我正在尝试为Google App Engine应用程序创建最简单的AJAX帖子示例...而且我失败了!
这是app python
import cgi
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
from django.utils import simplejson
class EmailItem(db.Model):
email = db.StringProperty(multiline=False)
date = db.DateTimeProperty(auto_now_add=True)
class EmailList(webapp.RequestHandler):
def get(self):
self.response.out.write("You see nothing!")
def post(self):
eitem = EmailItem()
eitem.email = self.request.get("address")
eitem.put()
self.response.out.write("success")
application = webapp.WSGIApplication([('/', EmailList)])
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
Run Code Online (Sandbox Code Playgroud)
这是jQuery
$.ajax({
type: "POST",
url: "myappengineURL",
data: "address=" + sVerifiedEmail,
success: function(msg) {
alert("Data Saved: " …Run Code Online (Sandbox Code Playgroud) 我在将jQueryUI组合框值绑定到我的KnockoutJS ViewModel中的计算observable时遇到问题.我发现了一些类似的问题,比如" autocomplete-combobox-with-knockout-js-template-jquery "和" knockoutjs-jquery-combobox-binding ",但都没有解决我的问题.
我认为这一切都是因为jQueryUI组合框在更新底层选择时不会触发更改事件.
我在这里举了一个例子...... http://jsfiddle.net/farina/hLfWa/
有人可以反转我正在使用的这个方便的哈希码吗?
using System.Security.Cryptography;
public static string EncodePasswordToBase64(string password)
{ byte[] bytes = Encoding.Unicode.GetBytes(password);
byte[] inArray = HashAlgorithm.Create("SHA1").ComputeHash(bytes);
return Convert.ToBase64String(inArray);
}
Run Code Online (Sandbox Code Playgroud)
我最终做的一切都失败了:(.
我到处寻找解决方案......即使谷歌自己的代码示例也不起作用.有人请向我解释如何调试事件监听器或至少如何使Console.Log()工作!
查看Google的示例:http://code.google.com/chrome/extensions/messaging.html
这是我正在测试的...在我的background.js上(从我的background.html引用)我有这个:
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
console.log(sender.tab ? "from a content script:" + sender.tab.url : "from the extension");
if (request.greeting == "hello")
sendResponse({farewell: "goodbye"});
else
sendResponse({}); // snub them.
});
Run Code Online (Sandbox Code Playgroud)
在我的popup.js(从我的popup.html引用)我有这个:
chrome.extension.sendRequest({greeting: "hello"}, function(response) {
console.log(response.farewell);
});
Run Code Online (Sandbox Code Playgroud)
考虑到我的清单中有以下权限:
"permissions": ["http://*/", "tabs"],
Run Code Online (Sandbox Code Playgroud)
我的内容脚本定义如下:
"content_scripts":
[
{
"matches": ["http://*/*", "https://*/*"],
"js": ["scripts/background.js"],
"all_frames": true
}
]
Run Code Online (Sandbox Code Playgroud)
为什么我无法从console.log获取任何信息或调试到事件中?我得到的反应很好......但是我无法调试?
谢谢您的帮助!
我不想创建一个JQUERY PLUGIN
假设我有这样的事情:
// In folib.js
function Foo() {this.Prop = function() {//do something}};
Run Code Online (Sandbox Code Playgroud)
所以我的用户可以引用我的JavaScript库并整天实例化我的对象
// In consumer
foo = new Foo();
alert(foo.Prop);
Run Code Online (Sandbox Code Playgroud)
现在,我想为我的类创建一个类似JQuery的插件系统,而我可以创建扩展Foo()的插件脚本库.
我想我应该这样做......
(function( foo ){
foo.myPlugin = function() {
// Do your awesome plugin stuff here
};
})(Foo);
Run Code Online (Sandbox Code Playgroud)
但我无法做到这一点.有关如何在JQuery中完成此操作的任何想法?我想不出来:(