Please indicate the source if you need to repost.

Client jQuery could initialize a cross-domain request. Certainly, jQuery could initialize a NetSuite request.

jQuery code (client):

        function clickMe() {
try {
var myUrl = your_http_url;
$.ajax({
url: myUrl,
dataType: 'jsonp',
data: { "myName1": 2345 },
jsonp: 'callback',
jsonpCallback: "asyncButton",
success: function (result) {
for (var i in result) {
alert(i + " : " + result[i]); //Print response result
}
},
error: function (result1) { alert(2) },
timeout: 3000
});
}
catch (ex) {
alert(ex);
}
}

Client jQuery

Suitelet code (server):

function asyncButton(request, response) {
var x = request.getParameter('myName1');
var y = request.getParameter('myName2');
nlapiLogExecution('debug','test',x+', '+y);
response.write('asyncButton({"myName":"DanielCai"})');
}

NetSuite Suietlet

Note: Suitelet MUST check the 'Available without login' option.

Howerver, this kind of request doesn't have any credentials, which means it's an insecure request.

Restlet seems an optiop. I tried with Restlet, it didn't work out.

I guess the reason why it failed:

Cross-domain request MUST set 'Access-Control-Allow-Origin' in the server headers.

And Restlet doesn't allow coder to set the headers, so doesn't Suitelet.

I think the 'Available without login' option set the headers for us. :)

That's why Suitelet works for client jQuery

// Allow all the other parties to access.
header('Access-Control-Allow-Origin:*');
// Response type
header('Access-Control-Allow-Methods:POST');
// Response headers
header('Access-Control-Allow-Headers:x-requested-with,content-type');

PHP Server

Client JQuery invoke NetSuite Suitelet的更多相关文章

  1. .NET invoke NetSuite Restlet

    Please indicate the source if you need to repost. Restlet allows programmers to use the http request ...

  2. 手机新闻网站,手持移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发

    我们坐在地铁.经常拿出新浪手机查看新闻.腾讯新闻,或者看新闻,等刷微信功能.你有没有想过如何实现这些目标. 移动互联网.更活泼. 由于HTML5未来,jQuery Moblie未来. 今天我用jqm的 ...

  3. 手机新闻网站,掌上移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发

    我们坐在地铁,经常来查看新浪手机新闻,腾讯新闻.或者刷微信看新闻更多功能.你有没有想过如何实现这些目标.移动互联网,更活泼. 因为HTML5到,jQuery Moblie到.今天我用jqm为了给你一个 ...

  4. JQuery invoke remote webservice

    Sending the Access-Control-Allow-Origin header allows basic cross-origin access, but calling ASP.NET ...

  5. Writing Your Own jQuery Plugins

    Setting Up <script src="js/jquery-1.9.1.min.js"></script> <script src=" ...

  6. org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Server returned error code = 404 for URI.. Check server logs for details

    严重: Servlet.service() for servlet jsp threw exceptionorg.codehaus.xfire.XFireRuntimeException: Could ...

  7. Learning WCF Chapter1 Generating a Service and Client Proxy

    In the previous lab,you created a service and client from scratch without leveraging the tools avail ...

  8. 【ASP.NET Web API教程】1.1 第一个ASP.NET Web API

    Your First ASP.NET Web API (C#)第一个ASP.NET Web API(C#) By Mike Wasson|January 21, 2012作者:Mike Wasson ...

  9. MSCRM 通过Ajax调用WCF服务

    Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...

随机推荐

  1. IP,路由,交换基础培训记录

    IP 掩码  子网划分 vlan划分(有助于减少广播压力) vlan之间互通通过交换机打通. 路由,静态路由,动态路由(学习到的),路由表,下一跳,网络位长的优先级高. 交换机,hub集线器. hub ...

  2. Android 软件开发之如何使用Eclipse Debug调试程序详解及Eclipse常用快捷键(转)

    1.在程序中添加一个断点如果所示:在Eclipse中添加了一个程序断点 在Eclipse中一共有三种添加断点的方法 第一种: 在红框区域右键出现菜单后点击第一项 Toggle Breakpoint 将 ...

  3. 使用国内镜像加速下载Android SDK

    本文转自:http://blog.kuoruan.com/24.html.感谢原作者. 什么是Android SDK SDK:(software development kit)软件开发工具包.被软件 ...

  4. fastcgi安装

    fastcgi安装 这里及以下的web服务器都是以nginx为例子和说明,php以5.3为例子. php-fpm fastcgi在服务器上会启动多个进程进行解析,这个时候就需要一个fastcgi的管理 ...

  5. 简单的描述Java中的构造函数,及访问修饰符

    作为一个Java 初学者,对Java的理解可能有些片面,甚至有些错误的理解,对于观看此处的您,希望您选择性观看!!! 访问修饰符: 1.常用访问修饰符: public 共有的 private 私有的 ...

  6. mvc 对一个或者多个实体验证失败

    为了解决“对一个或者多个实体验证失败”,关闭调用SaveChanges() 的实体属性合法性验证(谨慎使用) db.Configuration.ValidateOnSaveEnabled = fals ...

  7. 【C#】第3章学习要点(二)自定义类和结构

    分类:C#.VS2015 创建日期:2016-06-19 使用教材:(十二五国家级规划教材)<C#程序设计及应用教程>(第3版) 一.要点概述 别人提供的类都是为了简化你的工作量用的,可是 ...

  8. Delphi Berlin 10.1 for iOS 成生 info.plist 顺序改变了

    在 Delphi Seattle 10 update 1 版本(含之前版本),只要 Project > Build 会立即生成 info.plist 如果需要修改 info.plist 可以利用 ...

  9. 三星s4刷机教程(卡刷)

    ···············使用到的工具···················手机助手(--推荐91助手).root精灵.Odin3 v3.07.recovery包.rom包 1.首先在电脑上安装9 ...

  10. Exception loading sessions from persistent storage

    严重: Exception loading sessions from persistent storage java.io.EOFException 删除Tomcat里面的work/Catalina ...