Java脚本不起作用 [英] Java script dont work

查看:87
本文介绍了Java脚本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用java脚本插入db

但是不工作

我的代码:

函数InsertComment(id){



$ .ajax({

url:/ tickets / AddComment /+ id,

type:GET ,

数据:{text:$(#txtName)。val()}

})。done(function(){

//这里放一个完成方法的代码

});



}



我尝试了什么:



i trace with firebug并且看到id有值但文本为空

#textname是输入的id

i use java script for insert to db
but dont work
my code :
function InsertComment(id) {

$.ajax({
url: "/tickets/AddComment/" + id,
type: "GET",
data: { text: $("#txtName").val() }
}).done(function () {
//here put a code for done method
});

}

What I have tried:

i trace with firebug and see id have value but text is null
#textname is id for input

推荐答案

.ajax({

url:/ tickets / AddComment /+ id,

类型:GET,

数据:{text:
.ajax({
url: "/tickets/AddComment/" + id,
type: "GET",
data: { text:


(#txtName)。val()}

})。done(function(){

//这里为完成方法添加代码

});



}



我的尝试:


带有firebug的
i跟踪并看到id有值但文本为空

#textname是输入的id
("#txtName").val() }
}).done(function () {
//here put a code for done method
});

}

What I have tried:

i trace with firebug and see id have value but text is null
#textname is id for input


只要确保你为元素使用正确的ID,因为这很重要,你在我尝试过的内容:一节中提到,

Just make sure you use the correct ID for the element, because that matters, you mention in your "What I have tried:" section,
引用:

#textname是输入的id

#textname is id for input

因此,在这种情况下,代码将如下所示:

So, in that case the code would be like the following,

function InsertComment(id) {


这篇关于Java脚本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆