jQuery: Use of undefined constant data assumed 'data'
- by morpheous
I am trying to use jQuery to make a synchronous AJAX post to a server, and get a JSON response back.
I want to set a javascript variable msg upon successful return
This is what my code looks like:
$(document).ready(function(){
$('#test').click(function(){
alert('called!');
jQuery.ajax({
async: false,
type: 'POST',
url: 'http://www.example.com',
data: 'id1=1&id2=2,&id3=3',
dataType: 'json',
success: function(data){ msg = data.msg; },
error: function(xrq, status, et){alert('foobar\'d!');}
});
});
[Edit]
I was accidentally mixing PHP and Javascript in my previous xode (now corrected). However, I now get this even more cryptic error message:
uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js :: anonymous :: line 19" data: no]
What the ... ?