/ / jquery mobile з проблемою ajax - java, javascript-events, jquery-mobile

jquery mobile з ajax problem - java, javascript-події, jquery-mobile

моя проблема полягає в тому, що коли я переходжу безпосередньо до цієї конкретної сторінки (newUserForm.jsp), я можу використовувати цей метод, натискаючи кнопку. Але коли я переходжу на цю сторінку після навігації на інших сторінках (http://localhost:8081/home.jsp#/newUserForm.jsp) клацання нічого не робить - не відображає ім'я на екрані. (newUserForm.jsp :)

<!DOCTYPE html>
<html>
<head>
<title>JQuery Mobile AJAX</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-    1.0a2.min.css" />
<script src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script>
</head>
<body>
<script>
$(function()
{
$("#callAjax").click(function()
{
var theName = $.trim($("#theName").val());
if(theName.length > 0)
{
$.ajax({
type: "POST",
url: "/callajax.jsp",
data: ({name: theName}),
cache: false,
dataType: "text",
success: onSuccess
});
}
});
$("#resultLog").ajaxError(function(event, request, settings, exception)
{
$("#resultLog").html("Error Calling: " + settings.url     + "<br />HTPP Code: " + request.status);
});
function onSuccess(data)
{
$("#resultLog").html("Result: " + data);
}
});
</script>
<div data-role="page" id="indexPage">
<div data-role="header">
<h1>JQuery Mobile</h1>
</div>
<div data-role="content">
<div data-role="fieldcontain">
<label for="theName">Please enter your name:</label>
<input type="text" id="theName" name="theName" value="" />
</div>
<input id="callAjax" type="button" value="Call Ajax" />
<div id="resultLog"></div>
</div>
<div data-role="footer">
<h1>AJAX Demo</h1>
</div>
</div>
</body>
</html>

Це розглядається як ajax-дзвінок? Я знайшов цей код під час подорожі в google ...

Дякую.

Відповіді:

-2 для відповіді № 1
$("#callAjax").bind("vclick",function(){...})

jQuery mobile використовує vclick, а не клацання