Have code structure like this :
SkillEidt.js (Javascript File):
var SkillEdit = ({
_designtemplate: ["", "input", "dropdownlist", "checkbox"],
_designTemplateData: {},
readValue: function() {
/* when try to read value from customer.Html it's null */
return this._designTemplateData;;
},
RequestResponse: function (data) {
/* able to get and set value from ajax call */
this._designTemplateData = data;
},
ajaxCall : function() {
$.ajax({
url: "/VendorDetails/GetVendorDetails",
type: "POST",
async: true,
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (result) {
alert(result.statusText);
},
success: function (result) {
requestReponse(result);
}
});
});
SkillEdit.ajaxCall() /* very important to set _designTemplateData data */
Customer.Html (page):
<script src="~/Scripts/SkillEdit.js"></script>
<script type="text/javascript">
function SomeBuuttonClickEvent() {
var notAbleToGetValue = SkillEdit.readValue();
}
</script>
------------------------------------------------------------------------
When debug and see SkillEdit.ajaxCall()
will call ajaxCall()
method and on success will call RequestResponse
and set _designTemplateData
. But When i click Button (SomeBuuttonClickEvent) on Customer.Html
page readValue
is returning null value. How can i set the _designTemplateData
data.
..
Have added $.ajax function. How to slove the problem by using any of the solution
What code need to be written inside :
RequestResponse: function (data) or ajaxCall : function()