Since you're not making a cross-domain request, why are you using JSONP instead of regular JSON? I would think you would just use JSON.
JSONP uses a <script> element instead of XMLHttpRequest, so most of the Ajax parameters like the beforeSend and error functions don't apply. I don't know what the "Invalid Json Primitive" message means or where it's coming from, though. That's not part of jQuery. -Mike > From: tep > > Any comment, waiting your help > > > tep wrote: > > > > Hello all, > > > > I am trying to create a widget within .NET that's why using > JSONP. But > > when i run the code below, i get the error 'Invalid Json > Primitive' on > > client side before calling web service , how can i handle that ? > > > > function test2() > > { > > var params = '{wdgtype:"1"}'; > > > > $.ajax({ > > type: "POST", > > url: "service.aspx/GetWidget", > > data: params, // Set Method Params > > beforeSend: function(xhr) { > > xhr.setRequestHeader("Content-length", > params.length); > > xhr.setRequestHeader("Content-type", > > "application/json; charset=utf-8");}, > > contentType: "application/json; charset=utf-8", > > dataType: "jsonp", > > jsonp:"onJsonPLoad", > > success: function(msg) { > > $("#showyrmwidget").html(msg.d); > > }, > > error: function(xhr,msg,e){ > > alert(xhr.responseText);//Error Callback > > } > > > > }); > > } > > > > function onJsonPLoad(data) > > { > > alert(data); > > } > > > > [WebMethod()] > > public static string GetWidget(string wdgtype) { > > return "test"; > > } > > > > Thanks > > > > > > -- > View this message in context: > http://www.nabble.com/Invalid-Json-Primitive-tp21229536s27240p > 21248615.html > Sent from the jQuery General Discussion mailing list archive > at Nabble.com. >