Is there a reason you can't use the $.getJSON function? (see
http://docs.jquery.com/Ajax#.24.getJSON.28_url.2C_params.2C_callback_.29)
It does the same thing as the $.get function but parses the JSON and
passes an object to your callback instead of a string.

If you do need to eval() it, you have to do this:

function(jsonString)
{
   var myObj;
   eval("myObj = " + jsonString);
   // myObj is now your data as an object
}

(which is exactly what happens automatically if you use $.getJSON)

Mark

On Jun 21, 4:49 am, amircx <[EMAIL PROTECTED]> wrote:
> umm. i tried it , not work!
>  i got in firebug this:
>
> uncaught exception: [object Object]
>
> {"statusmsg":"1","errmsg":"0","desiredurl":"sddadandsadsad-as"}
>
> http://localhost/includes/private/php/checkVars.php?bn=sddad&gn=sadsa...
>
> $.get("/includes/private/php/checkVars.php", {
>         bn: bridename, gn: groomname,
> bl:bridelast,gl:groomlast,what:"SuggestSiteName"}, function(data){
>
> var myObj = eval(data);
> alert(myObj.statusmsg);
> alert(myObj.errmsg);
>   }
>
> ideas?
>
>
>
> Christopher Jordan wrote:
>
> > you say that json returns:
>
> > {"statusmsg":"1","errmsg":"0","desiredurl":"dsfandsdfdsf-ds"}
>
> > is that right? is the problem that you don't know how to access what is
> > being returned? If that's the case then you'll need to eval what comes
> > back. So lets say that:
>
> > var myReturnString =
> > {"statusmsg":"1","errmsg":"0","desiredurl":"dsfandsdfdsf-ds"}
>
> > then you'd need to do an: eval on myReturnString to turn that into a
> > JavaScript Object which you could then access like this:
>
> > var myObj = eval(myReturnString);
> > alert(myObj.statusmsg);
> > alert(myObj.errmsg);
>
> > etc.
>
> > Does that help?
>
> > Chris
>
> > amircx wrote:
> >> hey. i cannot return the parameters from json , im using .get and also in
> >> the
> >> same page i got the validation of jorn 's form (maybe its conflicts ?)
>
> >> herer is the code
> >> hope some1 will help
> >> json returns :
> >> {"statusmsg":"1","errmsg":"0","desiredurl":"dsfandsdfdsf-ds"}
>
> >> function ChangeUrlSite() {
> >> var bridename=$("#bride_name").val();
> >> var groomname=$("#groom_name").val();
> >> var bridelast=$("#bride_last").val();
> >> var groomlast=$("#groom_last").val();
>
> >> $.get("/includes/private/php/checkVars.php", {
> >>         bn: bridename, gn: groomname,
> >> bl:bridelast,gl:groomlast,what:"SuName"}, function(data){
>
> >>  alert(data.statusmsg.value);
> >>  //$("#desiredUserName").html(data);
> >>   }
> >> );
>
> >> }
> >> $("#bride_name,#groom_name,#bride_last,#groom_last").click( function() {
> >> ChangeUrlSite(); } );
> >>                                 </script>
>
> > --
> >http://www.cjordan.us
>
> --
> View this message in 
> context:http://www.nabble.com/need-hellp-with-.get-and-json-tf3952917s15494.h...
> Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to