views:

54

answers:

3

I'm relatively new to JQuery, so before I try to build the actual app, I'm trying to build a simple Ajax script that'll simply return the data.

However, despite more or less copying and pasting the code, I still can't get it to work.

<html>
<head>
<title>This is a title!</title>

<script src="scripts/jquery-1.4.2.min.js" type="text/javascript" charset="utf-8"></script>

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

$.ajax({
 url: 'process.php',
 dataType: "html",
 success: function(data) {
$('#testsite').html(data);
alert('Load was performed.');
}
});

alert ('2'); 
});
</script>
</head>
<body>
<div id='login'>
 <div id='testsite'>
</div>
<input type='button' id='lsubmit' value='Submit' />
</div>
</body>
</html>

The JQuery script is definitely loaded, process.php is definitely called up (it creates a text file just to prove that it has in fact been run) but anything echo'd in the process.php doesn't get sent through as data.

It's probably something simple, but I've run out of ideas.

Thanks in advance

A: 

Hey,

You will want to add an error handler, see if that gets fired, and inspect the error that is happening.... Add a callback to error.

HTH.

Brian
I put in an error handler but it doesn't get triggered.
Dolondro
A: 

Okay, this was major stupidity on my part. I messed up the process.php file so it didn't have any data to return

I have no memory of doing this and no idea why I did. Sorry for wasting your time and thanks to all those that helped =]

Dolondro
as others said , firebug is very nice tool. It shows you the ajax call the resonse from process.php and you can easily notice the error. If you are use ie , please use fiddler.
gov
A: 

Try using these

$.get('ajax/test.html', function(data) { $('.result').html(data); alert('Load was performed.'); });

$.post('ajax/test.html', function(data) { $('.result').html(data); });

even you solve yur problem , you can try these

zod