Unable to get values in POST php web serivce

旧巷老猫 提交于 2019-12-12 04:57:18

问题


I have made web service in php, which sends email to seller with information which is sent in parameters. If we are sending those information in GET, the web service works well. But if we send that information in POST, the web service (php script) shows nothing.

Here is url of that web service :

http://demo1.zenithtechnosol.net/carsGuide/contactSeller.php?seller_id=0&name=Anjum&email=abc@ccc.com&mobile=00923344239490&area=Dubai&message=This%20is%20test%20message.

Currently i am just showing param passed using

print_r($_REQUEST);

Well this is working fine because i am sending those paramerters in GET but I am trying to send those parameters in POST using chrome extension "Simple REST client", I am getting nothing.

I guess, I need to set headers in my script, but not sure about that. Or when calling that web service we need to set any thing header in request.

Here is how request via POST is send :

Ext.Ajax.request({
                url: this.getBaseUrl() + webServiceUrl,
                timeout: 240000,
                method: httpMethod,
                disableCaching: false,
                useDefaultXhrHeader: false,
                jsonData : {
             "seller_id":seller_id,
             "name":name,
             "email":email,
             "mobile":mobile,
             "area":area,
             "message":message              },
                scope: me,
                success: function(response) {
                 Ext.Viewport.unmask();
                    successCallBack(response);
                },
                failure: function(response) {
                 Ext.Viewport.unmask();
                   failureCallback(response);
                }
            });

Any help would be highly appreciated..

Thanks.. Anjum


回答1:


Try putting the jsonData in params as follows :

Ext.Ajax.request({
            url: this.getBaseUrl() + webServiceUrl,
            timeout: 240000,
            method: httpMethod,
            disableCaching: false,
            useDefaultXhrHeader: false,
            params: {
              jsonData : {
                   "seller_id":seller_id,
                   "name":name,
                   "email":email,
                   "mobile":mobile,
                   "area":area,
                   "message":message              },
            }},
            success: function(response){
            var text = response.responseText;
            // process server response here
}
});


来源:https://stackoverflow.com/questions/23563588/unable-to-get-values-in-post-php-web-serivce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!