6
मैं एक विजेट SalesForce में जावास्क्रिप्ट और jQuery का उपयोग कर बनाने के लिए कोशिश कर रहा हूँ की 'noConflict', मैं एक त्रुटि के साथ फंस गया था: Uncaught TypeError: कॉल नहीं कर सकता विधि अपरिभाषितUncaught TypeError: कॉल नहीं कर सकता विधि अपरिभाषित
की 'noConflict'नीचे मेरी कोड है जो मैं
(function() {
// Localize jQuery variable
var $j;
/******** Load jQuery if not present *********/
if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') {
var script_tag = document.createElement('script');
script_tag.setAttribute("type","text/javascript");
script_tag.setAttribute("src",
"https://ap1.salesforce.com/resource/go/jquery.min.js");
if (script_tag.readyState) {
script_tag.onreadystatechange = function() { // For old versions of IE
if (this.readyState == 'complete' || this.readyState == 'loaded') {
scriptLoadHandler();
}
};
} else {
script_tag.onload = scriptLoadHandler;
}
// Try to find the head, otherwise default to the documentElement
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
// The jQuery version on the window is the one we want to use
$j = window.jQuery;
main();
}
/******** Called once jQuery has loaded ******/
function scriptLoadHandler() {
// Restore $ and window.jQuery to their previous values and store the
// new jQuery in our local jQuery variable
$j = window.jQuery.noConflict(true);
// Call our main function
main();
}
/******** Our main function ********/
function main() {
$j(document).ready(function($) {
/******* Load CSS *******/
var css_link = $("<link>", {
rel: "stylesheet",
type: "text/css",
href: "style.css"
});
css_link.appendTo('head');
/******* Load HTML *******/
var jsonp_url = "http://al.smeuh.org/cgi-bin/webwidget_tutorial.py?callback=?";
$.getJSON(jsonp_url, function(data) {
$('#example-widget-container').html("This data comes from another server: " + data.html);
});
});
}
})(); // We call our anonymous function immediately
उपयोग कर रहा हूँ ब्राउज़र कंसोल त्रुटि में scriptLoadHandler समारोह की पहली पंक्ति की ओर इशारा कर रहा है।
आप अपने पृष्ठ –
में jQuery शामिल नहीं किया है हाँ, मैं, मैं इसे गतिशील रूप से चेक द्वारा शामिल कर रहा हूँ के साथ अपने मौजूदा या नहीं है, तो आप में देख सकते हैं उपरोक्त कोड की तीसरी पंक्ति। –
जब मैं https://ap1.salesforce.com/resource/go/jquery.min.js खोलता हूं तो इसमें jquery कोड नहीं लगता है। क्या आपने कहीं और jquery सहित कोशिश की है? – Reason