I am fairly new to AJAX
I have a webpage (say webpage A) which upon a certain button press, calls webpage B through AJAX. webpage B is having 2 javascript files included. Now whenever I click the button, the javascript files are not being loaded. its correspoing CSS files are loaded successfully by AJAX. Here is what I got after inspection-

Here arise my question 1- how is it making call to wdm.js? = some random number ??
Now, for the workaround, I have tried to load the javascript files by using jQuery.getScript() function using this code-
$.ajax({
type: "POST", url: "webpageB.php", data: "id="+id,
complete: function(data){
//some code
$.getScript('js/wdm.js');
// some code
}
});
still I am getting this error now-
Now my question 2 arises here- Why is that the random number, came out of nowhere, is appearing into ajax GET request?
I can not use the javascript on webpage A for some reasons, So the only option left is to load the javascripts dynamically (synchronously with DOM elements of webpage B). Can anyone suggest some method?

Edited- using the function ajaxsetup do remove the random number appearing in the URL, but now I see the file is still not being loaded by ajax, even though chrome inspector(which I use to monitor the ajax calls) do not show any errors. Now the situation is bit complex.
Random number is timestamp which is used to prevent browser's cache. If that's not what you want, add cache : true option in ajax call. For example: $.ajax({url: "url", success: callback, cache: true});. If you want to prevent all future AJAX requests from being cached by default(this is actually the default setting in jQuery):
$(document).ready(function() {
$.ajaxSetup({ cache: true });
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With