admin管理员组文章数量:1022769
I've built a test client page and I'm trying to post to a Web API that I've built, but I get the following error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'val'
on the following code:
<!DOCTYPE html>
<html xmlns="">
<head>
<title></title>
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnSubmit").click(function () {
var user = {
email: ('#txtEmail').val(),
password: ('#txtPassword').val(),
firstName: ('#txtFirstName').val(),
lastName: ('#txtLastName').val(),
country: ('#txtCountry').val(),
postal: ('#txtPostal').val()
};
$.post("http://myUrl/api/****/***************", user, function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
I can hit the service in Fiddler with the intended result, so I don't think its my service.
Also, I found a question on Stack talking about a similar issue regarding changing:
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
to
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js" />
but when I try this, I get an intellisense error in Visual Studio on that line wanting to change it back to the original line of code.
I'm still getting familiar with jquery, so that skillset isn't that strong yet. I know I'm missing something, but not sure what. If anyone could shed some light on the issue, I'd appreciate it.
I've built a test client page and I'm trying to post to a Web API that I've built, but I get the following error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'val'
on the following code:
<!DOCTYPE html>
<html xmlns="http://www.w3/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnSubmit").click(function () {
var user = {
email: ('#txtEmail').val(),
password: ('#txtPassword').val(),
firstName: ('#txtFirstName').val(),
lastName: ('#txtLastName').val(),
country: ('#txtCountry').val(),
postal: ('#txtPostal').val()
};
$.post("http://myUrl/api/****/***************", user, function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
I can hit the service in Fiddler with the intended result, so I don't think its my service.
Also, I found a question on Stack talking about a similar issue regarding changing:
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
to
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js" />
but when I try this, I get an intellisense error in Visual Studio on that line wanting to change it back to the original line of code.
I'm still getting familiar with jquery, so that skillset isn't that strong yet. I know I'm missing something, but not sure what. If anyone could shed some light on the issue, I'd appreciate it.
Share Improve this question asked May 15, 2014 at 15:13 Rex_CRex_C 2,4777 gold badges36 silver badges56 bronze badges 2-
1
you're missing the
$
... eg:$('#txtEmail').val(),
etc – Moob Commented May 15, 2014 at 15:14 -
You're missing the
$
from your selectors, eg:email: $('#txtEmail').val()
– Rory McCrossan Commented May 15, 2014 at 15:14
1 Answer
Reset to default 5you are missing $
:
email: $('#txtEmail').val()
it should be like:
var user = {
email: $('#txtEmail').val(),
password: $('#txtPassword').val(),
firstName: $('#txtFirstName').val(),
lastName: $('#txtLastName').val(),
country: $('#txtCountry').val(),
postal: $('#txtPostal').val()
};
I've built a test client page and I'm trying to post to a Web API that I've built, but I get the following error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'val'
on the following code:
<!DOCTYPE html>
<html xmlns="">
<head>
<title></title>
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnSubmit").click(function () {
var user = {
email: ('#txtEmail').val(),
password: ('#txtPassword').val(),
firstName: ('#txtFirstName').val(),
lastName: ('#txtLastName').val(),
country: ('#txtCountry').val(),
postal: ('#txtPostal').val()
};
$.post("http://myUrl/api/****/***************", user, function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
I can hit the service in Fiddler with the intended result, so I don't think its my service.
Also, I found a question on Stack talking about a similar issue regarding changing:
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
to
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js" />
but when I try this, I get an intellisense error in Visual Studio on that line wanting to change it back to the original line of code.
I'm still getting familiar with jquery, so that skillset isn't that strong yet. I know I'm missing something, but not sure what. If anyone could shed some light on the issue, I'd appreciate it.
I've built a test client page and I'm trying to post to a Web API that I've built, but I get the following error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'val'
on the following code:
<!DOCTYPE html>
<html xmlns="http://www.w3/1999/xhtml">
<head>
<title></title>
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#btnSubmit").click(function () {
var user = {
email: ('#txtEmail').val(),
password: ('#txtPassword').val(),
firstName: ('#txtFirstName').val(),
lastName: ('#txtLastName').val(),
country: ('#txtCountry').val(),
postal: ('#txtPostal').val()
};
$.post("http://myUrl/api/****/***************", user, function (data, status) {
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
I can hit the service in Fiddler with the intended result, so I don't think its my service.
Also, I found a question on Stack talking about a similar issue regarding changing:
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js"></script>
to
<script type="text/javascript" src="Scripts/jquery-2.1.1.min.js" />
but when I try this, I get an intellisense error in Visual Studio on that line wanting to change it back to the original line of code.
I'm still getting familiar with jquery, so that skillset isn't that strong yet. I know I'm missing something, but not sure what. If anyone could shed some light on the issue, I'd appreciate it.
Share Improve this question asked May 15, 2014 at 15:13 Rex_CRex_C 2,4777 gold badges36 silver badges56 bronze badges 2-
1
you're missing the
$
... eg:$('#txtEmail').val(),
etc – Moob Commented May 15, 2014 at 15:14 -
You're missing the
$
from your selectors, eg:email: $('#txtEmail').val()
– Rory McCrossan Commented May 15, 2014 at 15:14
1 Answer
Reset to default 5you are missing $
:
email: $('#txtEmail').val()
it should be like:
var user = {
email: $('#txtEmail').val(),
password: $('#txtPassword').val(),
firstName: $('#txtFirstName').val(),
lastName: $('#txtLastName').val(),
country: $('#txtCountry').val(),
postal: $('#txtPostal').val()
};
本文标签: javascriptObject doesn39t support property or method 39val39 on ajax POST to Web ApiStack Overflow
版权声明:本文标题:javascript - Object doesn't support property or method 'val' on ajax POST to Web Api - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745540515a2155161.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论