-1

I am using the following code in index.html

<html>
<head>
<title>Ajax check</title>
<script type="text/javascript" src="jquery-1.8.3.min.js" /> 

<script type="text/javascript">
$(document).ready(function(){

alert('working...');
$('#ibutton').click(function(e){
e.preventDefault();
alert('double click');      
$.ajax({
url: "page.html",
cache: false,
success: function(){
$("#message").val('ajax working..');
},
error: function(){
$("#message").val('error in the page');
}
});
}); 
});
</script>
</head>
<body> 
<form action="page.html">
<input type="button" id="ibutton" value="click here"/>
<div id="message"></div>
</form>
</body>
</html>

In page.html, the only content is 'working...' when I click the click here button... nothing happens.. what is wrong in the code?

1
  • For the doubt which is asked before 'when I click click here button.. nothing happerns' it is rectified by changing <script type="text/javascript" src="jquery-1.8.3.min.js" > </script> instead of <script type="text/javascript" src="jquery-1.8.3.min.js" /> .. and using $(#message).text('ajax working..') instead of $(#message).val('ajax working..') , script works fine and shows 'error in page'.. please rectify why it is displaying error? Commented Jan 12, 2013 at 6:41

1 Answer 1

2

The bug is the val function. I think that you want to use text function instead of val:

$("#message").text('ajax working..');
Sign up to request clarification or add additional context in comments.

5 Comments

still that change text instead of val is not working. and event alert('working'); is also not executed
Verify with other browser. I tested with chrome and it worked.
Nop. Only valto text and used chrome.
your tips worked.. but i have another problem facing.. please re-read the question..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.