내 코드가 작동하지만 html로 호출해도 작동하지 않는다면 이해가되지 않습니다. 나는 HTML에서 호출하는 경우 그것은 나에게 오류 잡히지 않은 TypeError : Request.callPost가 함수가 아닙니다.
Uncaught TypeError: Request.call Post is not a function
이유
을 제공?<button onclick="Request.callPost('/Api/Page/start/','mypost')" >My button</button>
<br> <br><br>
(function($){
$(document).ready(function(){
var Request={
init:function(){
this.callPost('/Api/Page/all','data'); //ok it work
},
callPost:function(link,data){
$.ajax({
url:link,
type:'POST',
data:data,
dataType:'json',
success:function(response){
console.log(response);
return response;
}
});
},
callGet:function(link,data){
$.ajax({
url:link,
type:'GET',
data:data,
dataType:'json',
success:function(response){
return response;
}
});
},
}
Request.init();
})
})(jQuery);