0

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>

<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").text('ajax working..');
},
error: function(){
$("#message").text('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... it shows 'error in the page'... what mistake I have done??

5
  • in IE it works fine but not in chrome Commented Jan 12, 2013 at 7:38
  • What is the error, when you click the click here button? Commented Jan 12, 2013 at 7:38
  • Oh I'm sorry.. Can you please alert the status code and thrown error in the error? Commented Jan 12, 2013 at 7:38
  • in IE it shows, ajax working but in chrome it shows error in the page Commented Jan 12, 2013 at 10:19
  • Can you please post the thrown javascript error? in .error, write this: function(req, opt, thrownerror){alert(thrownerror);}. And post here the alerted stuff ;) Commented Jan 12, 2013 at 10:54

1 Answer 1

1

Make sure that the page.html is in the same folder as the current page. There is not anything wrong with your code. Furthermore, I tested your code in my computer, and it worked like a charm. It seems like the only problem here is the page.html is not in the same folder as the currently working script.

Sign up to request clarification or add additional context in comments.

1 Comment

page.html, index.html, jquery-1.8.3.min.js are in same folder.. it is working fine in IE9 ('ajax working' inside #message) but in chrome it shows 'error in the page' inside #message.. is it working in chrome for you?

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.