I’m relatively new to SuiteCRM. When I do an AJAX call using jQuery from a custom form and a custom entry point I get the JSON I ask for, but it also returns a bunch of HTML and JS, causing an error. I’ll show code below and appreciate any help. Thanks!
SuiteCRM 7.13
JavaScript / jQuery
$.ajax({
method: "POST",
url: '/index.php?entryPoint=FindContacts&module=My_Module&to_pdf=1',
data: {my_data: myData}
}).done(function(data, textStatus, jqXHR) {
console.log(data);
});
I set up my entry point according to the documentation:
This is what is returned. The JSON is what my entry point is returning, and the rest is the undesirable HTML / JS.
{"message":"No results."} <-- MY JSON
A SNIPPET OF THE OTHER DATA RETURNED (that I thought was suppressed with to_pdf=1)
<div class="clear"></div>
<div class='listViewBody'>
<script type="text/javascript" src="include/javascript/popup_parent_helper.js?v=-p6kmkC1-L0iwsb5UaV6Tg"></script>
<script></script>
<script>
function addXMLRequestCallback(callback) {
var oldSend, i;
if (XMLHttpRequest.callbacks) {
// we've already overridden send() so just add the callback
XMLHttpRequest.callbacks.push(callback);
} else {
// create a callback queue
XMLHttpRequest.callbacks = [callback];
// store the native send()
oldSend = XMLHttpRequest.prototype.send;
// override the native send()
XMLHttpRequest.prototype.send = function () {
// process the callback queue
for (i = XMLHttpRequest.callbacks.length - 1; i >= 0; i--) {
XMLHttpRequest.callbacks[i](this);
}
// call the native send()
oldSend.apply(this, arguments);
}
}
}
function refreshSearchForm() {
$('.search_form textarea').each(function (i, e) {
$(e).css('max-width', $(e).parent().width());
});
Thanks for looking, and any help! Have a good day!!!