这个错误一直出现,所以希望你在这里说清楚,我的代码如下:
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js/"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js/"></script>
<script type="text/ecmascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/ecmascript" src="/_layouts/15/sp.js"></script>
<script>
function funcionX() {
//$("#submit-button").click(function () {
var context = SP.ClientContext.get_current();
alert('Entro');
var movies = context.get_web().get_lists().getByTitle("Movies");
var movieCreationInfo = new SP.ListItemCreationInformation();
var movie = movies.addItem(movieCreationInfo);
movie.set_item("Title", $("#movie-title").val());
movie.set_item("MovieDescription", $("#movie-description").val());
movie.update();
context.load(movie);
context.executeQueryAsync(success, failure);
function success() {
$("#movies-output").text("Created movie!");
};
function failure() {
$("#movies-output").text("Something failded");
};
};
</script>
Title: <input type="text" id="movie-title" /> <br />
Description: <input type="text" id="movie-description" /> <br />
<button type="button" id="submit-button" onclick="funcionX()">Add Movie</button>
<div id="movies-output"></div>
我理解错误是因为我的浏览器无法识别jquery,对吗?
感谢您的帮助,对不起的英语感到抱歉!
答案 0 :(得分:2)
只需删除js库URL中的尾部斜杠:
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js/"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js/"></script>
为:
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
答案 1 :(得分:1)
尝试使用JQuery noConflict并解决问题。
<script>
$.noConflict();
jQuery( document ).ready(function( $ ) {
// Code that uses jQuery's $ can follow here. });
// Code that uses other library's $ can follow here.
</script>