开发者

Using rel=value inside of getJson

开发者 https://www.devze.com 2023-03-23 05:34 出处:网络
Let\'s say I have this script: $(\'.myDiv\').click(function(){ $.getJSON(\'http://example.com/t.php\', {

Let's say I have this script:

$('.myDiv').click(function(){
     $.getJSON('http://example.com/t.php', {
          department: 'department',
          manufacturer: ''
}

What is the correct syntax to have a parameter's[manufacturer] value be represented by something like this:

<div class="myDiv" rel="brand=myBrand">Hello World</div>

How can the开发者_StackOverflow社区 value of the manufacturer parameter be defined by the relationship of the div?


you can do

$('.myDiv').click(function(){
     $.getJSON('http://example.com/t.php', {
          department: 'department',
          manufacturer: $('div.myDiv').attr('rel')
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号