post antiforgerytoken jquery
@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "__AjaxAntiForgeryForm" }))
{
@Html.AntiForgeryToken()
}
<div id="myDiv" data-url="@Url.Action("Index", "Home")">
Click me to send an AJAX request to a controller action
decorated with the [ValidateAntiForgeryToken] attribute
</div>
<script type="text/javascript">
$('#myDiv').submit(function () {
var form = $('#__AjaxAntiForgeryForm');
var token = $('input[name="__RequestVerificationToken"]', form).val();
$.ajax({
url: $(this).data('url'),
type: 'POST',
data: {
__RequestVerificationToken: token,
someValue: 'some value'
},
success: function (result) {
alert(result.someValue);
}
});
return false;
});
</script>
Also in JavaScript:
- javascript getmonth
- express get full url
- angular for loop
- node js http request get parameters
- react return action in a function
- js get current seconds
- all math methos js
- get start of day javascript
- react useref in useeffect
- mongodb delete duplicate documents
- javascript subtract years from date
- parse csv javascript
- ajouter un lien href dans du javascript
- how to pass dynamic string in string javascript
- javascript Convert an array of objects to a single object
- how to dynamically show image from local storage in react native
- react check if string is mail
- javascript array exists check
- javascript shuffle array
- square root js
- parent class and add element addclass
- number is even or odd fucntion in javascript
- puppeteer example nodejs
- convert number to array javascript