다음은 잘 작동하는 링크입니다. 그것은 구글 API에서 Gmail 연락처를 가져옵니다 : 나는 div
버튼을 통해이 기능을 반복하려고시뮬레이션 <a> jquery를 통한 href 게시
<a id='gmailInvite' class="button icon chat" href="<?php echo site_url('main/gmail_invite'); ?>"><span>Import GMail Contacts</span></a>
연결합니다.
사업부 버튼
<div class="gmailbutton" onclick="importGMailContacts()"><span class="textwhite">Import Gmail Contacts</span></a>
function importGMailContacts()
{
var form_data = "";
$.ajax({
url: "<?php echo site_url('main/gmail_invite'); ?>",
type: 'POST',
data: form_data,
success: function(msg) {
alert(msg)
return true;
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(xhr.responseText);
alert(thrownError);
}
});
}
나는이 방법을 컨트롤러로가는 DIV 버튼을 클릭합니다. 그러나 아무 일도 일어나지 않습니다. div 버튼에서 href post
을 어떻게 시뮬레이트 할 수 있습니까?
데이터를 form_data로 설정하는 것은 비어 있습니다. . . 그게 의도적 인거야? – ernie
예. 그냥 그 방법을 치고 싶다. –