admin管理员组文章数量:1404569
I've been developing a callcenter app with twilio and laravel 5.5, I want to get webrtc capabilities in my app and for that i have to use ajax to make requests.
however i am getting the following warning:
jQuery.Deferred exception: $.ajax is not a function @http://localhost:8000/js/browser-calls.js:14:2 l@http://localhost:8000/js/jquery.js:2:29373 a/http://localhost:8000/js/jquery.js:2:2967
with the following error:
TypeError: $.ajax is not a function
I've searched high and low for solutions and I've tried the folowing:
download jquery from the cdn to client and include it
try the latest CDN
<script src=".3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
- Tested in edge, chrome, firefox
- check if I'm not accidentally using the slim build
- place everything in my app.blade.php's header below jquery instead of right before the
</body>
<script src=".3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<script type="text/javascript" src="//media.twiliocdn/sdk/js/client/v1.3/twilio.min.js"></script>
<script type="text/javascript" src="{{ asset('js/browser-calls.js') }}"></script>
nothing has been able to resolve the issue, this is my ajax call
/* get twilio token with AJAX request */
var clientName = $('#agent-name').data('name');
$.ajax({
type: 'POST',
url: '/twilio/generate-token',
data: {
clientName: clientName,
},
success: function(data) {
Twilio.Device.setup(data.token);
}
});
i also tried the $.post
instead of $.ajax
but it resulted in the same error.
$.post('/twilio/generate-token', {
clientName: clientName,
clientToken: this.clientToken
}, function(data) {
Twilio.Device.setup(data.token);
});
What the hell is causing the $.ajax
function to not be recognized..
I've been developing a callcenter app with twilio and laravel 5.5, I want to get webrtc capabilities in my app and for that i have to use ajax to make requests.
however i am getting the following warning:
jQuery.Deferred exception: $.ajax is not a function @http://localhost:8000/js/browser-calls.js:14:2 l@http://localhost:8000/js/jquery.js:2:29373 a/http://localhost:8000/js/jquery.js:2:2967
with the following error:
TypeError: $.ajax is not a function
I've searched high and low for solutions and I've tried the folowing:
download jquery from the cdn to client and include it
try the latest CDN
<script src="http://code.jquery./jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
- Tested in edge, chrome, firefox
- check if I'm not accidentally using the slim build
- place everything in my app.blade.php's header below jquery instead of right before the
</body>
<script src="http://code.jquery./jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<script type="text/javascript" src="//media.twiliocdn./sdk/js/client/v1.3/twilio.min.js"></script>
<script type="text/javascript" src="{{ asset('js/browser-calls.js') }}"></script>
nothing has been able to resolve the issue, this is my ajax call
/* get twilio token with AJAX request */
var clientName = $('#agent-name').data('name');
$.ajax({
type: 'POST',
url: '/twilio/generate-token',
data: {
clientName: clientName,
},
success: function(data) {
Twilio.Device.setup(data.token);
}
});
i also tried the $.post
instead of $.ajax
but it resulted in the same error.
$.post('/twilio/generate-token', {
clientName: clientName,
clientToken: this.clientToken
}, function(data) {
Twilio.Device.setup(data.token);
});
What the hell is causing the $.ajax
function to not be recognized..
- The error implies that you're using the 'slim' branch of jquery, which does not have AJAX and several other features. You said you've tried to add a full version of jQuery, but ensure you only include that version, and have removed any previous ones. – Rory McCrossan Commented Feb 7, 2018 at 9:45
- And make sure include jQuery before you include your js-code, so jQuery is available when your code is executed. – KungWaz Commented Feb 7, 2018 at 9:46
- it apparently was caused by the app.js from laravel, if i load my local jquery and all the other scripts after the app.js it seems to work – Wouter Van Hees Commented Feb 7, 2018 at 10:03
3 Answers
Reset to default 3The jquery liberary was included before the app.js
script from laravel itself, after i moved the jquery cdn below the defenition of app.js
the problem was fixed
I had the same issue, but fixed it by adding this line:
<script src="https://ajax.aspnetcdn./ajax/jQuery/jquery-3.3.1.min.js"></script>
I faced same issue and got a better solution, than including a second jQuery. As I found out the app.js requires bootstrap.js.
In bootstrap.js the "jquery/dist/jquery.slim.js" is loaded, just change this to: "jquery/dist/jquery.min.js" and after repiling and loading page a few times the issue is solved in a cleaner way.
So problem was that the slim version of jQuery was loaded, which indeed does not contain any ajax feature.
本文标签: javascriptLaravel 55 jQuery 331 ajax is not a functionStack Overflow
版权声明:本文标题:javascript - Laravel 5.5 jQuery 3.3.1 ajax is not a function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744845435a2628173.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论