Here is the HTML (This form may use more than twice) :-(
这是HTML(此表单可能使用两次以上):-(
<div class="abc">
<div class="xyz">
<input type="text" name="pqr" />
<div class="clickMe">click button</div>
<div class="showContent"></div>
</div>
<div class="somethingelse">some other insignificent input or something else.</div>
</div>
Here is the jQuery:
这是jQuery:
$('.clickMe').on('click', function(e){
$.post("getdata.php", $(this).closest('.abc').children('.xyz').children('input[name="pqr"]').serialize(), function(response) {
$(this).closest('.abc').children('.xyz').children('.showContent').html(response);
});
});
i need only to check data of input(pqr) with my database?
any idea, how can i it and what is wrong on my code!
Advance thanks.
我只需要用我的数据库检查输入数据(pqr)?任何想法,我怎么能和我的代码有什么问题!谢谢。
1 个解决方案
#1
2
The scope of this
inside of the post is not the same as outside
帖子内部的范围与外部不同
$('.clickMe').on('click', function(e){
e.preventDefault();
var xyz = $(this).closest('.abc').children('.xyz');
$.post("getdata.php", xyz.children('input[name="pqr"]').serialize(), function(response) {
xyz.children('.showContent').html(response);
});
});
#1
2
The scope of this
inside of the post is not the same as outside
帖子内部的范围与外部不同
$('.clickMe').on('click', function(e){
e.preventDefault();
var xyz = $(this).closest('.abc').children('.xyz');
$.post("getdata.php", xyz.children('input[name="pqr"]').serialize(), function(response) {
xyz.children('.showContent').html(response);
});
});