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