Chris,

My XML file content is:

<?xml version="1.0" encoding="UTF-8"?>
<Module>
    <ModulePrefs title="Gadget title">
        <Require feature="settitle" />
        <Require feature="dynamic-height" />
    </ModulePrefs>
    <Content type="html">
        <![CDATA[
                <script language="javascript" type="text/javascript" src="
http://localhost/jquery-1.2.3.js";></script>
                <script  src="http://localhost/SSHD/js/jquery.dimensions.js";
type="text/javascript"></script>
                <div id="ajaxResponse">
                </div>
                <script language="javascript">
                    alert($);
                    var params = {};
                    var url = "http://localhost/makeRequestTest.php";;
                    params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.TEXT;
                    params[gadgets.io.RequestParameters.METHOD] =
gadgets.io.MethodType.POST;
                    var postData = {
                        GadgetID: "1",
                        GadgetMinimized : false
                    };
                    postData = gadgets.io.encodeValues(postData);
                    alert(postData);
                    params[gadgets.io.RequestParameters.POST_DATA] =
postData;
                    gadgets.io.makeRequest(url, function( objResponse ){
                        $("#ajaxResponse").html(objResponse.text);
                    }, params);
                </script>
            ]]>
    </Content>
</Module>

My PHP File content is:

<?php
    print_r($_REQUEST);
?>

It is working fine.
But when I change my PHP file content to

<?php
    json_encode($_REQUEST);
?>

I am getting response as below:

throw 1; < don't be evil'
>{"http://localhost/makeRequestTest.php":{"body":"\r\n","rc":200}}


Even though I used json_encode, the response will be in String format...

I am getting the same response even if I change some part of my XML file as
below:

params[gadgets.io.RequestParameters.CONTENT_TYPE] =
gadgets.io.ContentType.JSON;

And

gadgets.io.makeRequest(url, function( objResponse ){
     $("#ajaxResponse").html(objResponse.data);
}, params);

I don't understand why it is working for TEXT response (not in the case
where I use json_encode) and not for JSON.

And I am getting the above error message...?




On Tue, Jun 10, 2008 at 6:57 PM, Chris Chabot <[EMAIL PROTECTED]> wrote:

> I have no idea, thats what I'm trying to figure out :)
>
> Does the gadget code your creating run on hi5/orkut?
>
>
> On Jun 10, 2008, at 3:05 PM, Neo Anderson wrote:
>
>  I am using Java version...
>>
>> What would be the problem?
>>
>> On Tue, Jun 10, 2008 at 4:39 PM, Chris Chabot <[EMAIL PROTECTED]> wrote:
>>
>>  Neo is using the Java version of shindig i believe, Arun the PHP version?
>>>
>>> If so i guess it's either a bug in both, or maybe a bug in how the
>>> features
>>> javascript deals with this?
>>>
>>>
>>> On Jun 10, 2008, at 10:43 AM, Neo Anderson wrote:
>>>
>>> Yes, I too got the same problem,
>>>
>>>>
>>>>
>>>>
>>>> On Tue, Jun 10, 2008 at 1:04 PM, Arun Kumar <
>>>> [EMAIL PROTECTED]>
>>>> wrote:
>>>>
>>>> No, when I am sending the Ajax request in the same way, I haven't got
>>>> any
>>>>
>>>>> errors and the JSON format returned is a valid one. But I don't know
>>>>> why
>>>>> it
>>>>> is not working here.
>>>>>
>>>>> Am I sending the data in POST request correctly?
>>>>>
>>>>> On Mon, Jun 9, 2008 at 5:30 PM, Chris Chabot <[EMAIL PROTECTED]>
>>>>> wrote:
>>>>>
>>>>> Hard to say right away but in it's self the code looks good. Maybe the
>>>>>
>>>>>> JSON format search.php returns is invald?
>>>>>>
>>>>>> On Mon, 2008-06-09 at 14:28 +0530, Neo Anderson wrote:
>>>>>>
>>>>>>  function sendRequest()
>>>>>>> {
>>>>>>> var params = {};
>>>>>>> var url = "http://localhost/Search.php";;
>>>>>>> params[gadgets.io.RequestParameters.CONTENT_TYPE] =
>>>>>>> gadgets.io.ContentType.JSON;
>>>>>>> params[gadgets.io.RequestParameters.METHOD] =
>>>>>>>
>>>>>>>  gadgets.io.MethodType.POST;
>>>>>>
>>>>>
>>>>>  params[gadgets.io.RequestParameters.POST_DATA] = "kwd=" + kwd +
>>>>>>
>>>>>>>
>>>>>>>  "&Type="
>>>>>>
>>>>>
>>>>>  +
>>>>>>
>>>>>>  Type +  "&SearchBy=" + By + "&render=json";
>>>>>>> gadgets.io.makeRequest(url, response, params);
>>>>>>> }
>>>>>>>
>>>>>>> function response(obj)
>>>>>>> {
>>>>>>> alert(obj.data); //alerts null
>>>>>>> }
>>>>>>> For normal ajax request, it is working fine (Getting response), But
>>>>>>>
>>>>>>>  here,
>>>>>>
>>>>>
>>>>>  I
>>>>>>
>>>>>>  am getting a null response.
>>>>>>>
>>>>>>> Is there any problem with this code?
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Jun 9, 2008 at 1:50 PM, Chris Chabot <[EMAIL PROTECTED]>
>>>>>>>
>>>>>>>  wrote:
>>>>>>
>>>>>
>>>>>
>>>>>>  Yes absolutely, thats what the gadgets.io.makeRequest(url, callback)
>>>>>>>
>>>>>>>> function is for!
>>>>>>>>
>>>>>>>> It proxy's your request through shindig (which is on the same domain
>>>>>>>>
>>>>>>>>  as
>>>>>>>
>>>>>>
>>>>>  the
>>>>>>
>>>>>>  gadget), so no problems with domain origin policy's
>>>>>>>
>>>>>>>>
>>>>>>>> Ps, if your trying to run 'existing' code in a gadget you could
>>>>>>>>
>>>>>>>>  consider
>>>>>>>
>>>>>>
>>>>>>  making a wrapper script that pretends it's your toolkit's
>>>>>>>
>>>>>>>>
>>>>>>>>  Ajax.Request
>>>>>>>
>>>>>>
>>>>>  function, but actually performs a makeRequest function,as an example,
>>>>>>
>>>>>>>
>>>>>>>>  I
>>>>>>>
>>>>>>
>>>>>  created such a thing for prototype.js Ajax.Request back in the 0.5
>>>>>>
>>>>>>>
>>>>>>>>  days
>>>>>>>
>>>>>>
>>>>>  (when gadgets.io.makeRequest was still called _IG_FetchContent):
>>>>>>
>>>>>>> http://www.chabotc.com/wp-content/uploads/2007/11/osajax.js
>>>>>>>>
>>>>>>>>    -- Chris
>>>>>>>>
>>>>>>>>
>>>>>>>> On Jun 9, 2008, at 8:38 AM, Neo Anderson wrote:
>>>>>>>>
>>>>>>>> I have my Container at port 80 and server at 8080. I am using ajax
>>>>>>>>
>>>>>>>>  in
>>>>>>>
>>>>>>
>>>>>  my
>>>>>>
>>>>>>  gadget (Content type="HTML"). So, my Ajax requests are failed
>>>>>>>
>>>>>>>>
>>>>>>>>>  (Permission
>>>>>>>>
>>>>>>>
>>>>>>  denied because iFrame source is at 8080 and files to which I am
>>>>>>>
>>>>>>>>
>>>>>>>>>  sending
>>>>>>>>
>>>>>>>
>>>>>>  Ajax
>>>>>>>
>>>>>>>> requests are at port 80). Is there any alternative for sending Ajax
>>>>>>>>> requests
>>>>>>>>> to my Files at port 80?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>
>

Reply via email to