<a class="removeApp" data-app="12">Close Something </a>
$('.removeApp').click(function (e) {
$.ajax({
async: false,
type: 'POST',
url: '@Url.Action("Remove", "Something")',
data: {
id: $(this).data("app")
},
success: function (result, data) {
console.log(this.data ); //gives id=12
console.log (this.data["id"] ) ///gives nothing how do i get just 12
}
})
});
I am trying to get the data that is passed by parameter name how can i do so?
Well the data should look something like "{'id' : 12}", this would then be JSON and you could use the jQuery.getJSON()
function and this would return a javascript object - which is what you want.
I think that currently you're getting a string equal to "id=12" as a response - all HTTP data is a string, that's just how it works.
You can parse the string with a bit of javascript:
var id = parseInt(data.split("=")[1]);
That's a bit hardcoded and ugly however.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.