javascript - Convert data attrs to get/post data -
how convert data attributes valid post (or get) data?
$('#nav').find('a').click(function(){ var params = $(this).data(); $.get({ type: "get", url: "/view/", data: params }); })
i error:
post http://127.0.0.1/site1/%5bobject%20object%5d/ 404 (not found)
you can use jquery.param(),
$('#nav').find('a').click(function(){ var params = $(this).data(); params = $.param(params); $.ajax({ type: "get" url: "/view/", data: params }); })
edit:
actually problem you're using $.get() method $.ajax().
$.get()
doesn't accepts ajax settings object. change $.ajax() don't need use params.
Comments
Post a Comment