Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
systems:yii2:using_ajax [2018/05/31 11:07] smayr [Using JQuery $.get() or $.post()] |
systems:yii2:using_ajax [2018/05/31 11:16] (current) smayr [Using JQuery $.get() or $.post()] |
||
---|---|---|---|
Line 136: | Line 136: | ||
== Using JQuery $.get() or $.post() == | == Using JQuery $.get() or $.post() == | ||
- | You can also get data without | + | You can also get data using a simplified |
+ | |||
+ | Using GET method: | ||
<code php> | <code php> | ||
- | <?= $form-> | + | <?= $form-> |
- | | + | ' |
- | | + | ' |
//var aUrl = " | //var aUrl = " | ||
var aUrl = "' | var aUrl = "' | ||
Line 146: | Line 148: | ||
$( "# | $( "# | ||
}); | }); | ||
- | ']); | + | ', |
- | ?> | + | ]) ?> |
</ | </ | ||
Line 159: | Line 161: | ||
| | ||
url: aUrl, | url: aUrl, | ||
- | dataType: " | ||
data: {id: anId}, | data: {id: anId}, | ||
success: function( data ) { | success: function( data ) { | ||
Line 168: | Line 169: | ||
console.log(" | console.log(" | ||
console.dir( xhr ); | console.dir( xhr ); | ||
- | } | + | }, |
+ | dataType: " | ||
}); | }); | ||
', | ', | ||
Line 211: | Line 213: | ||
$( " | $( " | ||
.append( "Name: " + data.name ) // John | .append( "Name: " + data.name ) // John | ||
- | .append( "Time: " + data.time ); // 2pm | + | .append( "Time: " + data.time ); // 2pm |
}, " | }, " | ||
</ | </ |