I don't know, what do you want to do there? You said this is for feedback,
so I assume you may want to display some kind of message after you receive
it.

Your server should send back a JSONP response of some sort. You can put any
kind of data you want in it, maybe a status code and an HTML message string?

For example, if your feedback URL receives this query string:

    ?callback=js1234&feedback=Great%20site%21

it could send back this JSONP response:

    js1234({
        "error": false,
        "message": "<div>Thanks for your feedback!</div>"
    })

And then in your getJSON callback, you would use response.error and
response.message to get that data.

You can extend it from there any way you want.

-Mike

> From: Sam
> 
> Thanks Mike!  I understand now why I need to do a GET and 
> can't do a POST.  What would I do in the function(response){} part?
> 
> On Aug 25, 4:13 pm, "Michael Geary" <[EMAIL PROTECTED]> wrote:
> > You can't do a cross-domain POST. JSON or JSONP don't add 
> this capability.
> > You just can't do it.
> >
> > You can do a cross-domain GET, of course, and use query 
> parameters to 
> > pass data to your server.
> >
> > So, you can use $.getJSON with query parameters in the URL and the 
> > callback= option for JSONP, and have your server return a JSONP 
> > payload with the results of your request.
> >
> >     $.getJSON(
> >         'http://example.com/feedback?callback=?&feedback='+
> >             encodeURIComponent(feedback),
> >         function( response ) {
> >             ...
> >         }
> >     );
> >
> > -Mike
> >
> > > From: Sam
> >
> > > I am creating a widget where someone can post a note 
> about the page 
> > > (feedback).  I am currently using AJAX to pass the 
> information to my 
> > > server, but I want to now use JSON, so that I can put it 
> on one of 
> > > my other domains and still send the info to my original domain.  
> > > This is the function I currently have:
> >
> > > function saveNote(obj, cancel) {
> > >     var note_html = $(obj).parents(".note");
> > >     var page_id = getPageId($(obj));
> > >     if(!cancel) {
> > >         var t = note_html.find("textarea").val();
> > >         var url = G_MAIN_DOMAIN + "/page/addNote";
> > >         $.post(url, { page_id: page_id, note: t 
> },function(data){});
> > >     } else {
> > >         var t = cancel;
> > >     }
> > >     if(t=='') t='(click to add text)';
> > >     note_html.html("<a href='#' class='edit_note'>" + t + "</
> > > a>");
> > > }
> >
> > > I want to change the $.post to something that sends out a JSON 
> > > object.  Do I need to create another function or how do I do this?
> > > Thanks for the help!
> 

Reply via email to