views:

45

answers:

3

I am trying this code in Javascript. But its not working.... The postData is json data sent to the server to be saved. I have checked that JSON data needs to be parsed or stringify... is that the problem.. or I am doing some other silly mistake...

var postData ="_out=json&name=justtryit&def={"layout":[{"id":"sw-156","xy":[168,80]},{"id":"_OUTPUT","xy":[508.33331298828125,95.81666564941406]}],"modules":[{"type":"fetch","id":"sw-156","conf":{"URL":{"value":"www.sports.yahoo.com","type":"url"}}},{"type":"output","id":"_OUTPUT","conf":{}}],"terminaldata":[],"wires":[{"id":"_w1","src":{"id":"_OUTPUT","moduleid":"sw-156"},"tgt":{"id":"_INPUT","moduleid":"_OUTPUT"}}]}&rnd=7821&.crumb=P.r4cQGAC.Y";

var handleSuccess = function(o)
{ 
if(o.responseText !== undefined)
  {
 alert('o.responseText');
   }
}

var handleSuccess = function(o)
{
}

var callback ={ success:handleSuccess,  failure: handleFailure, argument: ['foo','bar']}; 

var request = YAHOO.util.Connect.asyncRequest('POST','http://pipes.yahoo.com/pipes/ajax.pipe.save' , callback, postData);
A: 

Actually what you have even not JSON string. It is just invalid string. You need to put it in ''.

var postData ='_out=json&name=justtryit&def={"layout":[{"id":"sw-156","xy":[168,80]},{"id":"_OUTPUT","xy":[508.33331298828125,95.81666564941406]}],"modules":[{"type":"fetch","id":"sw-156","conf":{"URL":{"value":"www.sports.yahoo.com","type":"url"}}},{"type":"output","id":"_OUTPUT","conf":{}}],"terminaldata":[],"wires":[{"id":"_w1","src":{"id":"_OUTPUT","moduleid":"sw-156"},"tgt":{"id":"_INPUT","moduleid":"_OUTPUT"}}]}&rnd=7821&.crumb=P.r4cQGAC.Y';

It should work if you are doing right call

Eldar Djafarov
Thanks for a answer... I just tried a above change putting single quotes instead of double quote..any oar problem you think can be?
Judy
Thanks for a answer Eldar... I tried a single quotes but it didn't worked....can you are be some oar problem ....
Judy
Check if there any call browser sends. Use firebug plugin for this in Firefox. Net tab.
Eldar Djafarov
+2  A: 

You have handleSuccess defined twice. The second time is a no-op. Get rid of the second 'var handleSuccess = ...' and put in a handleFailure definition.

seth
A: 

Thanks Seth your valuable information helped... Thanks a lot

Judy