jQuery ajax responseText empty
I ran into a problem using the $.ajax command synchronously in jQuery. I'd make my call. But when I get the XMLHttpRequest object back, the responseText was empty. My call looked like this.
After wasting 2 hours trying to figure out what was wrong, I noticed that I had a spelling error in my request object. The asynch should be async (no h). I fixed this typo and everything started working as it should.
So if you can't get the jQuery ajax command to work synchronously and return the responseText, check your calling object. The JSON format is very convenient, but if you make a mistake in the naming of a parameter it just gets ignored and you're left scratching your head.
var response = $.ajax({
url: '/formCheck',
type: 'POST',
cache: false,
asynch: false,
data: postObj,
});
console.log(response.responseText);
After wasting 2 hours trying to figure out what was wrong, I noticed that I had a spelling error in my request object. The asynch should be async (no h). I fixed this typo and everything started working as it should.
So if you can't get the jQuery ajax command to work synchronously and return the responseText, check your calling object. The JSON format is very convenient, but if you make a mistake in the naming of a parameter it just gets ignored and you're left scratching your head.
| Rating: | 100% positive, 4 total Votes |
| Categories: | javascript jQuery programming |
| Added: | on Mar 27, 2009 at 8:26 am |
| Added By: | an anonymous user |
| Searches: | jquery javascript programming responsetext ajax |

