Created
September 12, 2017 08:27
-
-
Save mahmut-gundogdu/f34ff931dc0c5e207fc018451b35f34f to your computer and use it in GitHub Desktop.
asp.net mvc de form içerisinde form açamıyoruz. bazen gerekiyor. Bu kod url verilen html getirip içerisindeki formu ajax ile ele almayı(handle) sağlıyor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getDataFromPartialbyAjax(url, mainPanel, callbackFn) { | |
function getModalData(response) { | |
if (response.data != undefined) { | |
//it is json | |
callbackFn(response.data); | |
mainPanel.empty(); | |
} else { | |
//it is html | |
mainPanel.html(response); | |
$.validator.unobtrusive.parse($("form", mainPanel)); | |
init(mainPanel); | |
var form = $('form', mainPanel); | |
form.on('submit', function () { | |
$.ajax({ | |
url: this.action, | |
type: this.method, | |
data: $(this).serialize(), | |
success: getModalData | |
}); | |
return false; | |
}); | |
} | |
} | |
$.get(url).success(getModalData); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment